/* ================================================
   CDGS Course Search v1.0.1 - Autocomplete Styles
   ================================================ */ 

/* Wrapper */
.cdgs-course-search-wrapper {
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    position: static;
    font-family: 'Anuphan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: #ffffff;
    padding: 50px 300px;
}

/* Container */
.cdgs-search-container {
    position: relative;
    width: 100%;
}

/* Input Wrapper */
.cdgs-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid #d4c4b0;
    border-radius: 50px;
    padding: 12px 20px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.cdgs-search-input-wrapper:focus-within {
    border-color: #c9b8a0;
    box-shadow: 0 4px 12px rgba(129, 199, 132, 0.15);
}

/* Search Icon */
.cdgs-search-icon {
    display: flex;
    align-items: center;
    color: #81c784;
    margin-right: 12px;
    flex-shrink: 0;
}

.cdgs-search-icon svg {
    color: #81c784;
}

/* Search Input */
.cdgs-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    color: #1f2937;
    background: transparent;
    font-family: inherit;
}

.cdgs-search-input::placeholder {
    color: #9ca3af;
}

/* Clear Button */
.cdgs-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
    margin-right: 4px;
}

.cdgs-search-clear:hover {
    background: #d1d5db;
}

.cdgs-search-clear svg {
    color: #6b7280;
}

/* Results Dropdown */
.cdgs-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cdgs-search-results-inner {
    padding: 8px;
}

/* Result Item */
.cdgs-search-result-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    gap: 12px;
}

.cdgs-search-result-item:hover {
    background: #f9fafb;
    transform: translateX(4px);
}

/* Thumbnail */
.cdgs-result-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.cdgs-result-no-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background: linear-gradient(135deg, #f0fdf4 0%, #dbeafe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cdgs-result-no-thumbnail svg {
    width: 30px;
    height: 30px;
    color: #4ade80;
}

/* Result Content */
.cdgs-result-content {
    flex: 1;
    min-width: 0;
}

.cdgs-result-title {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cdgs-result-title mark {
    background: #fff59d;
    color: #f57f17;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 700;
}

.cdgs-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6b7280;
    flex-wrap: wrap;
}

.cdgs-result-category {
    background: #f0fdf4;
    color: #15803d;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.cdgs-result-instructor {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cdgs-result-instructor::before {
    content: '👤';
}

/* Loading State */
.cdgs-search-loading {
    padding: 20px;
    text-align: center;
    color: #6b7280;
}

.cdgs-search-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #e5e7eb;
    border-top-color: #81c784;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* No Results */
.cdgs-search-no-results {
    padding: 30px 20px;
    text-align: center;
    color: #9ca3af;
}

.cdgs-search-no-results-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.cdgs-search-no-results-text {
    font-size: 15px;
    margin: 0;
}

/* ================================================
   STYLE: HERO (Large search box)
   ================================================ */

.cdgs-search-hero .cdgs-search-input-wrapper {
    padding: 18px 28px;
    border-radius: 60px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    border: 2px solid #d4c4b0;
}

.cdgs-search-hero .cdgs-search-input {
    font-size: 18px;
}

.cdgs-search-hero .cdgs-search-icon svg {
    width: 24px;
    height: 24px;
    color: #81c784;
}

/* ================================================
   STYLE: MINIMAL (Compact search box)
   ================================================ */

.cdgs-search-minimal .cdgs-search-input-wrapper {
    padding: 8px 16px;
    border-radius: 22px;
    border: 1px solid #d4c4b0;
}

.cdgs-search-minimal .cdgs-search-input {
    font-size: 14px;
}

.cdgs-search-minimal .cdgs-search-icon svg {
    width: 16px;
    height: 16px;
    color: #81c784;
}

.cdgs-search-minimal .cdgs-result-thumbnail,
.cdgs-search-minimal .cdgs-result-no-thumbnail {
    width: 40px;
    height: 40px;
}

/* ================================================
   RESPONSIVE DESIGN
   ================================================ */

@media (max-width: 1920px) {
    .cdgs-course-search-wrapper {
        padding: 50px 350px;
    }
}

@media (max-width: 1440px) {
    .cdgs-course-search-wrapper {
        padding: 50px 300px;
    }
}

@media (max-width: 1200px) {
    .cdgs-course-search-wrapper {
        padding: 50px 150px;
    }
}

@media (max-width: 992px) {
    .cdgs-course-search-wrapper {
        padding: 50px 100px;
    }

    .cdgs-search-input-wrapper {
        padding: 10px 16px;
    }

    .cdgs-search-input {
        font-size: 15px;
    }

    .cdgs-result-thumbnail,
    .cdgs-result-no-thumbnail {
        width: 50px;
        height: 50px;
    }

    .cdgs-result-title {
        font-size: 14px;
    }

    .cdgs-result-meta {
        font-size: 12px;
    }

    .cdgs-search-results {
        max-height: 300px;
    }

    .cdgs-search-hero .cdgs-search-input-wrapper {
        padding: 14px 20px;
    }

    .cdgs-search-hero .cdgs-search-input {
        font-size: 16px;
    }
}

@media (max-width: 768px) {
    .cdgs-course-search-wrapper {
        padding: 20px 60px;
    }

    .cdgs-search-input-wrapper {
        padding: 10px 16px;
    }

    .cdgs-search-input {
        font-size: 15px;
    }

    .cdgs-result-thumbnail,
    .cdgs-result-no-thumbnail {
        width: 50px;
        height: 50px;
    }

    .cdgs-result-title {
        font-size: 14px;
    }

    .cdgs-result-meta {
        font-size: 12px;
    }

    .cdgs-search-results {
        max-height: 300px;
    }
}

@media (max-width: 576px) {
    .cdgs-course-search-wrapper {
        padding: 20px 30px;
    }

    .cdgs-search-input-wrapper {
        padding: 8px 12px;
        border-radius: 25px;
    }

    .cdgs-search-input {
        font-size: 14px;
    }

    .cdgs-result-thumbnail,
    .cdgs-result-no-thumbnail {
        width: 40px;
        height: 40px;
    }

    .cdgs-search-result-item {
        padding: 8px;
    }

    .cdgs-result-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        font-size: 11px;
    }

    .cdgs-search-icon {
        margin-right: 8px;
    }

    .cdgs-search-icon svg {
        width: 18px;
        height: 18px;
    }

    .cdgs-search-hero .cdgs-search-input-wrapper {
        padding: 12px 16px;
    }

    .cdgs-search-hero .cdgs-search-input {
        font-size: 15px;
    }

    .cdgs-search-results {
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    .cdgs-course-search-wrapper {
        padding: 20px 20px;
    }

    .cdgs-search-input-wrapper {
        padding: 8px 12px;
    }

    .cdgs-search-input {
        font-size: 13px;
    }

    .cdgs-result-thumbnail,
    .cdgs-result-no-thumbnail {
        width: 40px;
        height: 40px;
    }

    .cdgs-search-result-item {
        padding: 6px;
    }

    .cdgs-result-title {
        font-size: 13px;
    }

    .cdgs-result-meta {
        font-size: 10px;
    }
}

/* ================================================
   SCROLLBAR STYLING
   ================================================ */

.cdgs-search-results::-webkit-scrollbar {
    width: 8px;
}

.cdgs-search-results::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

.cdgs-search-results::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.cdgs-search-results::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ================================================
   KEYBOARD NAVIGATION
   ================================================ */

.cdgs-search-result-item.keyboard-focus {
    background: #f0fdf4;
    outline: 2px solid #86efac;
    outline-offset: -2px;
}

/* ================================================
   ACCESSIBILITY
   ================================================ */

.cdgs-search-input:focus {
    outline: none;
}

.cdgs-search-input-wrapper:focus-within {
    outline: 2px solid #81c784;
    outline-offset: 2px;
}

/* Screen Reader Only */
.cdgs-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ================================================
   ANIMATION & TRANSITIONS
   ================================================ */

.cdgs-search-result-item {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation */
.cdgs-search-result-item:nth-child(1) { animation-delay: 0.05s; }
.cdgs-search-result-item:nth-child(2) { animation-delay: 0.1s; }
.cdgs-search-result-item:nth-child(3) { animation-delay: 0.15s; }
.cdgs-search-result-item:nth-child(4) { animation-delay: 0.2s; }
.cdgs-search-result-item:nth-child(5) { animation-delay: 0.25s; }
