/* === CSS Variables === */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;

    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-dark: #1e293b;
    --bg-sidebar: #1e293b;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;

    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);

    --sidebar-width: 260px;
    --topnav-height: 70px;

    --transition: all 0.3s ease;
}

/* === Base Styles === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

/* === App Container === */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-white);
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--primary-light);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin: 0.25rem 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--border-radius-sm);
    color: var(--text-light);
    transition: var(--transition);
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-white);
}

.nav-link.active {
    background: var(--primary-color);
    color: var(--text-white);
}

.nav-link i {
    width: 20px;
    text-align: center;
}

.nav-divider {
    margin: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* === Main Wrapper === */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* === Top Navigation === */
.top-nav {
    height: var(--topnav-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.search-box {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-box input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-primary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--border-color);
}

.btn-icon .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger-color);
    color: white;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
}

.user-dropdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.user-dropdown:hover {
    background: var(--border-color);
}

.user-dropdown .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.user-dropdown span {
    font-weight: 500;
}

.user-dropdown .fa-chevron-down {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* === Main Content === */
.main-content {
    flex: 1;
    padding: 1.5rem;
}

/* === Page Header === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* === Cards === */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
}

.card-body {
    padding: 1.25rem;
}

/* === Stats Cards === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.primary { background: rgba(99, 102, 241, 0.1); color: var(--primary-color); }
.stat-icon.success { background: rgba(34, 197, 94, 0.1); color: var(--success-color); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning-color); }
.stat-icon.danger { background: rgba(239, 68, 68, 0.1); color: var(--danger-color); }
.stat-icon.info { background: rgba(59, 130, 246, 0.1); color: var(--info-color); }

.stat-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

/* === Tables === */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
    padding: 0.75rem 1rem;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: var(--bg-primary);
}

/* === Badges === */
.badge {
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.75rem;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Status badges */
.badge-planning { background: rgba(155, 89, 182, 0.1); color: #9b59b6; }
.badge-inprogress { background: rgba(52, 152, 219, 0.1); color: #3498db; }
.badge-onhold { background: rgba(243, 156, 18, 0.1); color: #f39c12; }
.badge-completed { background: rgba(39, 174, 96, 0.1); color: #27ae60; }
.badge-cancelled { background: rgba(231, 76, 60, 0.1); color: #e74c3c; }

/* Priority badges */
.badge-low { background: rgba(149, 165, 166, 0.1); color: #95a5a6; }
.badge-medium { background: rgba(52, 152, 219, 0.1); color: #3498db; }
.badge-high { background: rgba(243, 156, 18, 0.1); color: #f39c12; }
.badge-critical { background: rgba(231, 76, 60, 0.1); color: #e74c3c; }

/* Task status */
.badge-todo { background: #6c757d; color: #ffffff; }
.badge-inprogress { background: #0d6efd; color: #ffffff; }
.badge-review { background: #fd7e14; color: #ffffff; }
.badge-done { background: #198754; color: #ffffff; }
.badge-blocked { background: #dc3545; color: #ffffff; }

/* Invoice status */
.badge-draft { background: rgba(149, 165, 166, 0.1); color: #95a5a6; }
.badge-sent { background: rgba(52, 152, 219, 0.1); color: #3498db; }
.badge-paid { background: rgba(39, 174, 96, 0.1); color: #27ae60; }
.badge-overdue { background: rgba(231, 76, 60, 0.1); color: #e74c3c; }

/* Incident types */
.badge-bug { background: rgba(231, 76, 60, 0.1); color: #e74c3c; }
.badge-issue { background: rgba(243, 156, 18, 0.1); color: #f39c12; }
.badge-request { background: rgba(52, 152, 219, 0.1); color: #3498db; }
.badge-enhancement { background: rgba(155, 89, 182, 0.1); color: #9b59b6; }

/* Severity */
.badge-open { background: rgba(52, 152, 219, 0.1); color: #3498db; }
.badge-resolved { background: rgba(39, 174, 96, 0.1); color: #27ae60; }
.badge-closed { background: rgba(149, 165, 166, 0.1); color: #95a5a6; }
.badge-reopened { background: rgba(243, 156, 18, 0.1); color: #f39c12; }

/* === Buttons === */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.btn-outline-primary {
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-light {
    background: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-light:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* === Forms === */
.form-control, .form-select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-text {
    color: var(--text-light);
    font-size: 0.8125rem;
}

/* === Progress Bar === */
.progress {
    height: 8px;
    border-radius: 4px;
    background: var(--bg-primary);
}

.progress-bar {
    background: var(--primary-color);
    border-radius: 4px;
}

/* === Auth Pages === */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 2rem;
}

.auth-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--text-secondary);
}

.auth-form .form-control {
    padding: 0.875rem 1rem;
}

.auth-form .btn {
    padding: 0.875rem 1.5rem;
    width: 100%;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary-color);
    font-weight: 500;
}

/* === Empty States === */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state i {
    font-size: 4rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-light);
}

/* === Pagination === */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.875rem;
    color: var(--text-secondary);
}

.page-link:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.page-item.active .page-link {
    background: var(--primary-color);
    color: white;
}

/* === Dropdowns === */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.dropdown-item:hover {
    background: var(--bg-primary);
}

/* === Notifications Dropdown === */
.notifications-dropdown {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item p {
    margin: 0;
    font-size: 0.875rem;
}

.notification-item small {
    color: var(--text-light);
}

/* === Project Card === */
.project-card {
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.project-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.project-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}

/* === Task List === */
.task-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.task-item:hover {
    background: var(--bg-primary);
}

.task-item:last-child {
    border-bottom: none;
}

.task-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.task-checkbox.checked {
    background: var(--success-color);
    border-color: var(--success-color);
}

.task-content {
    flex: 1;
}

.task-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.task-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-light);
}

/* === Kanban Board === */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-column {
    min-width: 300px;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 1rem;
}

.kanban-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.kanban-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.kanban-count {
    background: var(--bg-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
}

.kanban-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.kanban-card:hover {
    box-shadow: var(--shadow);
}

/* === Activity Timeline === */
.activity-timeline {
    position: relative;
    padding-left: 2rem;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.activity-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 0.25rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid var(--bg-secondary);
}

.activity-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
}

/* === Responsive === */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }
}

@media (max-width: 767.98px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .search-box {
        display: none;
    }
}

/* === Utility Classes === */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

.fw-semibold {
    font-weight: 600;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }

/* === Print Styles === */
@media print {
    .sidebar, .top-nav, .btn, .no-print {
        display: none !important;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .main-content {
        padding: 0;
    }
}
