:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #f8fafc;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --secondary: #6366f1;
    --border: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* Authentication Layout */
#auth-container {
    display: none;
    height: 100vh;
    width: 100%;
    padding: 5rem 1rem;
    background: radial-gradient(circle at top right, #6366f1, #4f46e5);
    background-attachment: fixed;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-direction: column;
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

.auth-brand svg {
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.auth-brand h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2.5rem;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 440px;
    margin: 2rem auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: max-width 0.3s ease;
}

.auth-card.wide {
    max-width: 50%;
    min-width: 320px;
}

.auth-card h2 {
    margin-bottom: 2rem;
    font-weight: 800;
    text-align: center;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group.full-width {
    grid-column: span 2;
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group.full-width {
        grid-column: span 1;
    }
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-error {
    background: var(--error);
    color: white;
}

.btn-error:hover {
    opacity: 0.9;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    width: auto;
    padding: 0.5rem 1rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    width: auto;
}

.btn-link {
    background: none;
    color: var(--primary);
    padding: 0.5rem;
    margin-top: 0.5rem;
    text-decoration: none;
    display: block;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: background 0.2s;
}

.btn-link:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* App Layout */
#app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
nav {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Main Content */
main {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Cards and Sections */
.page-section {
    display: none;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.page-section.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Tables */
.table-container {
    background: white;
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow: hidden;
}

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

th {
    background: #f8fafc;
    text-align: left;
    padding: 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

tr:last-child td {
    border-bottom: none;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Buttons */
.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    width: auto;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: var(--text-muted);
}

/* Notifications */
#toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    background: var(--sidebar-bg);
    color: white;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(150%);
    transition: transform 0.3s;
    z-index: 1000;
}

#toast.show {
    transform: translateY(0);
}

/* Loading Indicators */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

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

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: calc(50% - 8px);
    left: calc(50% - 8px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

.btn-outline.btn-loading::after {
    border-top-color: var(--primary);
    border-color: rgba(99, 102, 241, 0.1);
}

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(2px);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

.modal {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 500px;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.close-modal {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-muted);
    border: none;
    background: none;
    line-height: 1;
}

.tab-btn {
    flex: 1;
    padding: 0.625rem;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.5);
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.info-card {
    transition: transform 0.2s;
}

.info-card:hover {
    transform: scale(1.02);
}

.tab-content {
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Planning Grid */
.planning-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 120px);
    margin-top: 1rem;
}

.employee-sidebar {
    background: white;
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.employee-list-item {
    padding: 1rem 1.25rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.employee-list-item:hover {
    background: rgba(var(--primary-rgb, 79, 70, 229), 0.05);
}

.employee-list-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.employee-list-item .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--primary);
}

.employee-list-item.active .avatar {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.tasks-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.planning-filters {
    background: white;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.task-calendar-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.date-divider {
    padding: 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.task-card {
    background: white;
    border-radius: 1rem;
    border: 1px solid var(--border);
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.task-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.task-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.task-card-title {
    font-weight: 700;
    color: var(--text-main);
    font-size: 1.05rem;
}

.task-card-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.task-card-actions {
    display: flex;
    gap: 0.5rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    text-align: center;
    background: white;
    border-radius: 1rem;
    border: 1px dashed var(--border);
}

/* Custom Searchable Dropdown */
.custom-dropdown {
    position: relative;
}

.dropdown-trigger {
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    font-family: inherit;
    color: var(--text-main);
}

.dropdown-trigger::after {
    content: '▾';
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.custom-dropdown.open .dropdown-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    border-radius: 0.5rem 0.5rem 0 0;
}

.dropdown-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--primary);
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
    z-index: 200;
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.15);
    max-height: 280px;
    display: none;
    flex-direction: column;
}

.custom-dropdown.open .dropdown-panel {
    display: flex;
}

.dropdown-search {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: none;
    border-bottom: 1px solid var(--border);
    outline: none;
    font-size: 0.875rem;
    font-family: inherit;
    background: #f8fafc;
}

.dropdown-search:focus {
    background: white;
}

.dropdown-items {
    overflow-y: auto;
    max-height: 220px;
}

.dropdown-item {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.1s;
    border-bottom: 1px solid var(--border);
}

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

.dropdown-item:hover {
    background: rgba(99, 102, 241, 0.08);
}

.dropdown-item.selected {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    font-weight: 600;
}

.dropdown-item.hidden {
    display: none;
}

/* Loading & Spinners */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 0.25rem;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}