/* ============================================
   REUSABLE COMPONENTS
   ============================================ */

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-5);
    font-size: var(--font-size-sm);
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1.5px solid transparent;
    transition: all var(--duration-fast) var(--ease-smooth);
    white-space: nowrap;
    height: 40px;
    cursor: pointer;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--gray-700);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.btn-success {
    background: var(--gradient-accent);
    color: #fff;
    border: none;
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-danger {
    background: var(--danger-500);
    color: #fff;
    border: none;
}

.btn-danger:hover {
    background: var(--danger-600);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
}

.btn-sm {
    height: 32px;
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
}

.btn-lg {
    height: 48px;
    padding: var(--space-3) var(--space-8);
    font-size: var(--font-size-base);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-icon.btn-sm { width: 32px; height: 32px; }

/* === Cards === */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    padding: var(--space-6);
    transition: all var(--duration-normal) var(--ease-smooth);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}

.card-title {
    font-size: var(--font-size-base);
    font-weight: 700;
}

.card-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

/* === Table === */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--gray-50);
    border-bottom: 2px solid var(--border-color);
}

.data-table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--duration-fast);
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* === Badges / Tags === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary { background: var(--primary-100); color: var(--primary-700); }
.badge-success { background: var(--accent-100); color: var(--accent-700); }
.badge-warning { background: var(--warm-100); color: var(--warm-600); }
.badge-danger { background: var(--danger-100); color: var(--danger-600); }
.badge-info { background: var(--info-100); color: var(--info-500); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* === Avatar === */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-sm);
    color: #fff;
    flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--font-size-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--font-size-lg); }
.avatar-xl { width: 80px; height: 80px; font-size: var(--font-size-2xl); }

.avatar-1 { background: var(--gradient-primary); }
.avatar-2 { background: var(--gradient-accent); }
.avatar-3 { background: var(--gradient-warm); }
.avatar-4 { background: var(--gradient-danger); }

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: var(--z-overlay);
    display: none;
    animation: fadeIn 0.2s;
}

.modal-overlay.active { display: block; }

.modal-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2xl);
    z-index: var(--z-modal);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    display: none;
    flex-direction: column;
    animation: slideUp 0.3s var(--ease-smooth);
}

.modal-container.active {
    display: flex;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-size: 1.5rem;
    color: var(--gray-400);
    transition: all var(--duration-fast);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-body {
    padding: var(--space-6);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-light);
}

/* === Toast Notifications === */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid;
    min-width: 320px;
    max-width: 440px;
    animation: slideInRight 0.3s var(--ease-smooth);
    font-size: var(--font-size-sm);
}

.toast.success { border-color: var(--accent-500); }
.toast.error { border-color: var(--danger-500); }
.toast.warning { border-color: var(--warm-500); }
.toast.info { border-color: var(--info-500); }

.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-message { flex: 1; }
.toast-close {
    color: var(--gray-400);
    cursor: pointer;
    padding: 2px;
    font-size: 1.2rem;
}

.toast.hiding {
    animation: slideOutRight 0.3s var(--ease-smooth) forwards;
}

/* === Empty State === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-16) var(--space-8);
    text-align: center;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: var(--font-size-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.empty-state p {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    max-width: 400px;
}

/* === Form Styles === */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.form-group {
    margin-bottom: var(--space-5);
}

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.form-group label .required {
    color: var(--danger-500);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* === Tabs === */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: var(--space-6);
    gap: 0;
}

.tab-btn {
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--duration-fast);
    cursor: pointer;
}

.tab-btn:hover { color: var(--gray-700); }

.tab-btn.active {
    color: var(--primary-600);
    border-color: var(--primary-500);
}

/* === Search & Filter Bar === */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.search-input {
    position: relative;
    max-width: 300px;
    flex: 1;
}

.search-input input {
    padding-left: 38px;
    height: 40px;
}

.search-input svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--gray-400);
}

.filter-select {
    height: 40px;
    min-width: 140px;
    font-size: var(--font-size-sm);
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    margin-top: var(--space-6);
}

.page-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-600);
    transition: all var(--duration-fast);
}

.page-btn:hover { background: var(--gray-100); }
.page-btn.active {
    background: var(--primary-500);
    color: #fff;
}

/* === Level Progress Bar === */
.progress-bar {
    height: 8px;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    overflow: hidden;
    width: 100%;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    transition: width 0.8s var(--ease-smooth);
}

/* === Calendar-like Schedule === */
.schedule-grid {
    display: grid;
    grid-template-columns: 80px repeat(7, 1fr);
    gap: 1px;
    background: var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.schedule-header {
    background: var(--gray-50);
    padding: var(--space-3);
    text-align: center;
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
}

.schedule-time {
    background: var(--gray-50);
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
}

.schedule-cell {
    background: var(--bg-secondary);
    min-height: 60px;
    padding: var(--space-1);
    position: relative;
}

.schedule-event {
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 2px;
    cursor: pointer;
    transition: transform var(--duration-fast);
}

.schedule-event:hover { transform: scale(1.02); }

.schedule-event.primary { background: var(--primary-100); color: var(--primary-700); border-left: 2px solid var(--primary-500); }
.schedule-event.success { background: var(--accent-100); color: var(--accent-700); border-left: 2px solid var(--accent-500); }
.schedule-event.warning { background: var(--warm-100); color: var(--warm-600); border-left: 2px solid var(--warm-500); }

/* === Search Results Dropdown === */
.header-search {
    position: relative;
}

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 360px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--border-light);
    z-index: 999;
    margin-top: 8px;
    max-height: 400px;
    overflow-y: auto;
    animation: slideDown 0.2s var(--ease-smooth);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-light);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--gray-50);
}

.search-result-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-weight: 600;
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* ============================================
   LEO OPTIMIZER COMPONENTS
   ============================================ */

/* === Star Input === */
.star-input {
    display: flex;
    align-items: center;
    gap: 4px;
}

.star-btn {
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--gray-300);
    transition: all 0.15s;
    user-select: none;
    line-height: 1;
}

.star-btn:hover { color: var(--warm-400); transform: scale(1.2); }
.star-btn.active { color: var(--warm-500); }

/* === Skill Bars === */
.leo-skill-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 0;
}

.leo-skill-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.leo-skill-label {
    width: 80px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-700);
    flex-shrink: 0;
}

.leo-skill-val {
    width: 50px;
    text-align: right;
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--gray-600);
    flex-shrink: 0;
}

/* === Score Input Group === */
.score-input-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.score-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.score-item label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--gray-600);
}

/* === Availability Grid === */
.availability-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    overflow-x: auto;
}

.avail-day-col {
    min-width: 100px;
}

.avail-day-header {
    text-align: center;
    font-weight: 700;
    font-size: var(--font-size-sm);
    padding: 10px 0;
    background: var(--gray-50);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    color: var(--primary-700);
    border-bottom: 2px solid var(--primary-200);
}

.avail-slots {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 4px;
}

.avail-slot-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: var(--radius-md);
    background: var(--gray-50);
    border: 1.5px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--gray-500);
    text-align: center;
}

.avail-slot-btn:hover {
    border-color: var(--primary-300);
    background: var(--primary-50, #eef2ff);
    color: var(--primary-600);
}

.avail-slot-btn.active,
.avail-slot-btn:has(input:checked) {
    background: var(--primary-500);
    color: #fff;
    border-color: var(--primary-500);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.avail-slot-btn input[type="checkbox"] {
    display: none;
}

/* === Milestone Timeline === */
.milestone-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.milestone-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 0;
    border-left: 3px solid var(--gray-200);
    margin-left: 14px;
    padding-left: 24px;
    position: relative;
}

.milestone-item.done {
    border-left-color: var(--accent-400);
}

.milestone-dot {
    position: absolute;
    left: -16px;
    top: 14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: var(--bg-secondary);
    border: 3px solid var(--gray-200);
}

.milestone-item.done .milestone-dot {
    border-color: var(--accent-400);
    background: var(--accent-50, #ecfdf5);
}

.milestone-info strong {
    font-size: var(--font-size-sm);
    display: block;
    margin-bottom: 2px;
}

/* === Responsive for LEO grid === */
@media (max-width: 768px) {
    .availability-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .score-input-group {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .availability-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .leo-skill-label {
        width: 60px;
        font-size: var(--font-size-xs);
    }
}
