/* ===========================
   COMPONENTS.CSS
   Shared UI components across all pages
   UTeM Expert Directory
=========================== */

/* ===========================
   CSS VARIABLES
=========================== */
:root {
    --primary-color: #082E72;
    --primary-hover: #0a3d96;
    --primary-light: #e3f2fd;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    
    /* Gradients */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --warning-gradient: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
    --info-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --highlight-gradient: linear-gradient(120deg, #fff176 0%, #ffeb3b 100%);
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
    --radius-full: 50%;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.2);
    --shadow-xl: 0 12px 40px rgba(0,0,0,0.25);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ===========================
   LANGUAGE SELECTOR
=========================== */
.lang-selector {
    position: absolute;
    top: 10px;
    right: 20px;
    z-index: 100;
}

.lang-selector select {
    min-width: 140px;
    background: rgba(255,255,255,0.9);
}

/* ===========================
   LOADING STATES
=========================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner,
.spinner-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: var(--primary-color);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

.spinner-custom {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.tab-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.tab-error {
    text-align: center;
    padding: 20px;
    color: #c33;
    background: #fee;
    border-radius: var(--radius-md);
    margin: 10px;
}

/* ===========================
   ERROR & SUCCESS MESSAGES
=========================== */
.error-message {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 15px;
    border-radius: var(--radius-md);
    text-align: center;
}

.error-message button {
    margin-top: 10px;
}

.success-message {
    background: #efe;
    border: 1px solid #cfc;
    color: #3c3;
    padding: 15px;
    border-radius: var(--radius-md);
    text-align: center;
}

/* ===========================
   AUTOCOMPLETE COMPONENT
=========================== */
.autocomplete-wrapper {
    position: relative;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 15px;
    color: var(--secondary-color);
    font-size: 1.1rem;
    pointer-events: none;
    transition: color var(--transition-normal);
}

.search-input-wrapper input {
    padding-left: 45px;
    padding-right: 15px;
}

.search-input-wrapper input::placeholder {
    font-size: 0.9rem;
    color: #999;
}

.search-input-wrapper input:focus + .search-icon,
.search-input-wrapper input:not(:placeholder-shown) + .search-icon {
    color: var(--primary-color);
}

.search-input-wrapper .loading-spinner {
    position: absolute;
    right: 15px;
    display: none;
}

.search-input-wrapper.loading .loading-spinner {
    display: block;
}

/* Focus visible for accessibility */
#searchName:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(8, 46, 114, 0.15);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 350px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity var(--transition-normal), 
                transform var(--transition-normal), 
                visibility var(--transition-normal);
}

.autocomplete-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.autocomplete-header {
    padding: var(--spacing-sm) 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 0.8rem;
    color: #666;
}

.autocomplete-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: all var(--transition-fast);
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fd 100%);
    padding-left: 20px;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item .name {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.autocomplete-item .name mark,
.autocomplete-item .info mark {
    background: var(--highlight-gradient);
    padding: 1px 4px;
    border-radius: 3px;
}

.autocomplete-item .info {
    font-size: 0.85rem;
    color: #555;
    margin-top: 4px;
}

.autocomplete-item .faculty {
    margin-top: 6px;
}

.autocomplete-loading,
.autocomplete-empty {
    padding: 20px;
    text-align: center;
    color: #888;
}

.autocomplete-empty i {
    font-size: 1.5rem;
    margin-bottom: 8px;
    display: block;
}

/* Focus visible for accessibility */
.autocomplete-item:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fd 100%);
}

/* Keyboard hint */
.keyboard-hint {
    font-size: 0.75rem;
    color: #888;
    margin-top: 5px;
    text-align: center;
}

.keyboard-hint kbd {
    background: #eee;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.7rem;
    font-family: inherit;
}

/* ===========================
   FACULTY BADGES
=========================== */
.faculty-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: var(--radius-xl);
    font-weight: 500;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.faculty-badge.fkaiks { background: #e3f2fd; color: #1565c0; }
.faculty-badge.ftmk { background: #f3e5f5; color: #7b1fa2; }
.faculty-badge.fkp { background: #e8f5e9; color: #2e7d32; }
.faculty-badge.fkekk { background: #fff3e0; color: #e65100; }
.faculty-badge.ftkip { background: #fce4ec; color: #c2185b; }
.faculty-badge.ftk { background: #e0f7fa; color: #00838f; }
.faculty-badge.fptt { background: #f1f8e9; color: #558b2f; }
.faculty-badge.default { background: #f5f5f5; color: #616161; }

/* ===========================
   STAT CARDS
=========================== */
.stat-card {
    background: var(--primary-gradient);
    color: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    transition: transform var(--transition-slow);
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card.success { background: var(--success-gradient); }
.stat-card.warning { background: var(--warning-gradient); }
.stat-card.info { background: var(--info-gradient); }
.stat-card.secondary { background: var(--secondary-gradient); }

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ===========================
   EXPERT CARDS
=========================== */
.expert-card {
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    background: #fff;
}

.expert-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(8, 46, 114, 0.15) !important;
    border-color: var(--primary-color);
}

.expert-card .card-body {
    flex: 1;
    padding: 1.5rem;
}

.expert-card .card-title {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    line-height: 1.4;
}

.expert-card .card-text mark {
    background: var(--highlight-gradient);
    padding: 1px 4px;
    border-radius: 3px;
}

/* Avatar */
.avatar-container {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    margin: 0 auto;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #e0e0e0;
}

.avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    font-size: 4rem;
    color: #ccc;
}

/* Card text */
.designation-text {
    font-size: 0.9rem;
    color: #555;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.faculty-text {
    font-size: 0.85rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.field-text {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 1rem;
    min-height: 2.5em;
}

/* ===========================
   BUTTONS
=========================== */
.btn-view-profile {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    padding: 8px 24px;
    border-radius: var(--radius-xl);
    font-size: 0.9rem;
    transition: all var(--transition-normal);
    color: #fff;
}

.btn-view-profile:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: scale(1.05);
    color: #fff;
}

.btn-primary-gradient {
    background: var(--primary-gradient);
    border: none;
    padding: 12px 30px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all var(--transition-slow);
    color: #fff;
}

.btn-primary-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

/* Quick Action Buttons */
.quick-action-btn {
    padding: 15px;
    border-radius: var(--radius-lg);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-slow);
    background: #f8f9fa;
    border: 2px solid #e9ecef;
}

.quick-action-btn:hover {
    background: #e9ecef;
    transform: translateY(-3px);
}

.quick-action-btn i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

/* ===========================
   FORM CONTROLS (Enhanced)
=========================== */
.form-control-enhanced,
.form-select-enhanced {
    border-radius: var(--radius-md);
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    transition: all var(--transition-slow);
}

.form-control-enhanced:focus,
.form-select-enhanced:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* ===========================
   DATA SECTIONS
=========================== */
.data-section {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

.section-title {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

/* ===========================
   INFO ROWS
=========================== */
.info-row {
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--secondary-color);
}

.info-value {
    color: #333;
}

/* ===========================
   PROFILE CARD
=========================== */
.profile-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
}

.profile-image {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 4px solid white;
    box-shadow: var(--shadow-md);
    margin-bottom: 15px;
}

/* ===========================
   JSON VIEWER
=========================== */
.json-viewer {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: var(--radius-lg);
    max-height: 500px;
    overflow: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.json-key { color: #9cdcfe; }
.json-string { color: #ce9178; }
.json-number { color: #b5cea8; }
.json-boolean { color: #569cd6; }
.json-null { color: #569cd6; }

/* ===========================
   SEARCH SECTION
=========================== */
.search-section {
    background: #f8f9fa;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.search-results-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
}

/* ===========================
   EMPTY STATE
=========================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--secondary-color);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* ===========================
   TABLE ENHANCEMENTS
=========================== */
.table-enhanced thead th {
    background: var(--primary-gradient);
    color: white;
    font-weight: 600;
    border: none;
    padding: 15px;
}

.table-enhanced tbody tr:hover {
    background-color: #f8f9fa;
}

/* Amount highlight */
.amount-highlight {
    color: var(--primary-color);
    font-weight: 700;
}

/* ===========================
   BADGE CUSTOM
=========================== */
.badge-custom {
    padding: 6px 12px;
    border-radius: var(--radius-xl);
    font-weight: 500;
}

/* ===========================
   PAGE HEADER (API Viewer style)
=========================== */
.page-header {
    background: var(--primary-gradient);
    color: white;
    padding: 25px;
    border-radius: var(--radius-lg);
    margin-bottom: 25px;
}

.page-header h1 {
    margin: 0;
    font-weight: 700;
}

.page-header p {
    margin: 10px 0 0;
    opacity: 0.9;
}

/* ===========================
   CONTROL PANEL
=========================== */
.control-panel {
    background: #f8f9fa;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #e9ecef;
}

/* ===========================
   NAV TABS ENHANCED
=========================== */
.nav-tabs-enhanced .nav-link {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-weight: 600;
    color: var(--primary-color);
}

.nav-tabs-enhanced .nav-link.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
}

.tab-content-enhanced {
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 20px;
    background: white;
}

/* ===========================
   RESPONSIVE ADJUSTMENTS
=========================== */
@media (max-width: 768px) {
    .expert-card .card-body {
        padding: 1rem;
    }
    
    .expert-card .card-title {
        font-size: 1rem;
    }
    
    .avatar-container {
        width: 100px;
        height: 100px;
    }
    
    .avatar-placeholder {
        font-size: 3rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    .page-header {
        padding: 15px;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .autocomplete-dropdown {
        max-height: 60vh;
        border-radius: 0 0 var(--radius-md) var(--radius-md);
    }
    
    .autocomplete-item {
        padding: 14px 12px;
        min-height: 48px; /* Touch-friendly */
    }
    
    .autocomplete-item .name {
        font-size: 0.95rem;
    }
    
    .autocomplete-item .info {
        font-size: 0.85rem;
    }
    
    .keyboard-hint {
        display: none;
    }
    
    #searchName {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
    
    .search-input-wrapper .search-icon {
        left: 12px;
        font-size: 1rem;
    }
    
    .search-input-wrapper input {
        padding-left: 38px;
        padding-right: 12px;
    }
}
