/* Prodlys - Modern Production Management System
   Brand Colors: Teal/Emerald primary with warm accents */

:root {
    /* Primary Brand Colors - Teal/Emerald (Professional, Growth, Manufacturing) */
    --primary: #0d9488;
    --primary-light: #14b8a6;
    --primary-dark: #0f766e;
    --primary-50: #f0fdfa;
    --primary-100: #ccfbf1;
    --primary-200: #99f6e4;
    
    /* Secondary - Slate (Professional, Clean) */
    --secondary: #475569;
    --secondary-light: #64748b;
    --secondary-dark: #334155;
    
    /* Accent - Amber (Energy, Attention) */
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --accent-dark: #d97706;
    
    /* Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;
    
    /* Neutrals */
    --dark: #0f172a;
    --gray-900: #1e293b;
    --gray-800: #334155;
    --gray-700: #475569;
    --gray-600: #64748b;
    --gray-500: #94a3b8;
    --gray-400: #cbd5e1;
    --gray-300: #e2e8f0;
    --gray-200: #f1f5f9;
    --gray-100: #f8fafc;
    --white: #ffffff;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Transitions */
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== AUTH PAGES ==================== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 50%, var(--primary-dark) 100%);
    position: relative;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    opacity: 0.1;
}

.auth-container::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -30%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    opacity: 0.05;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 480px;
    padding: 48px;
    position: relative;
    z-index: 1;
    border: 1px solid var(--gray-200);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
    box-shadow: var(--shadow-lg);
}

.auth-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.5px;
}

.auth-logo p {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 32px;
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 12px 16px;
    text-align: center;
    cursor: pointer;
    color: var(--gray-600);
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 0.95rem;
}

.auth-tab:hover {
    color: var(--gray-900);
}

.auth-tab.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: var(--transition);
    background: var(--white);
    color: var(--gray-900);
}

.form-control:hover {
    border-color: var(--gray-400);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-control.error {
    border-color: var(--danger);
}

.form-control::placeholder {
    color: var(--gray-400);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 44px;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 28px 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-200);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
    white-space: nowrap;
    /* Mobile touch improvements */
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    user-select: none;
    -webkit-user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    box-shadow: 0 2px 4px rgb(13 148 136 / 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgb(13 148 136 / 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--gray-600);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--gray-700);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary-50);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-warning:hover {
    background: var(--accent-dark);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #059669;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

/* ==================== ALERTS ==================== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #a7f3d0;
}

.alert-warning {
    background: var(--warning-light);
    color: var(--accent-dark);
    border: 1px solid #fde68a;
}

.alert-info {
    background: var(--info-light);
    color: var(--info);
    border: 1px solid #93c5fd;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--gray-500);
    font-size: 0.85rem;
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}


/* ==================== DASHBOARD LAYOUT ==================== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, var(--gray-900) 0%, var(--gray-800) 100%);
    color: var(--white);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: var(--transition-slow);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.3px;
}

.sidebar-header small {
    display: block;
    color: var(--gray-400);
    font-size: 0.8rem;
    margin-top: 2px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-nav {
    padding: 16px 0;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    padding: 12px 24px 8px;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: 1.2px;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: var(--gray-400);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    margin: 2px 0;
}

.nav-link i {
    margin-right: 14px;
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.nav-link:hover {
    background: rgba(255,255,255,0.05);
    color: var(--white);
}

.nav-link.active {
    background: rgba(13, 148, 136, 0.15);
    color: var(--primary-light);
    border-left-color: var(--primary);
}

.nav-link.active i {
    color: var(--primary-light);
}

/* Report Submenu */
.report-submenu {
    margin-left: 15px;
    border-left: 2px solid var(--gray-700);
    padding-left: 10px;
    display: none;
}

.report-submenu.open {
    display: block;
}

.report-submenu .nav-link {
    font-size: 0.85rem;
    padding: 8px 12px;
}

.nav-link.has-submenu {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-link.has-submenu .chevron {
    transition: transform 0.2s;
}

.nav-link.has-submenu.open .chevron {
    transform: rotate(90deg);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 32px;
    background: var(--gray-100);
    min-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.5px;
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info .avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 0.9rem;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gray-50);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ==================== STATS GRID ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.stat-card.teal::before { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.stat-card.green::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card.amber::before { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.stat-card.red::before { background: linear-gradient(90deg, var(--danger), #f87171); }

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-card.teal .stat-icon { background: var(--primary-100); color: var(--primary); }
.stat-card.green .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.amber .stat-icon { background: var(--warning-light); color: var(--accent); }
.stat-card.red .stat-icon { background: var(--danger-light); color: var(--danger); }

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
    letter-spacing: -1px;
}

.stat-card .stat-label {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

.stat-card .stat-change {
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-card .stat-change.positive { color: var(--success); }
.stat-card .stat-change.negative { color: var(--danger); }

/* ==================== TABLES ==================== */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 14px 16px;
    text-align: left;
}

th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}

td {
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
    font-size: 0.9rem;
}

tr:hover td {
    background: var(--gray-50);
}

tr:last-child td {
    border-bottom: none;
}

/* ==================== BADGES ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-planned { 
    background: var(--info-light); 
    color: var(--info); 
}
.badge-released { 
    background: var(--primary-100); 
    color: var(--primary-dark); 
}
.badge-closed { 
    background: var(--success-light); 
    color: var(--success); 
}
.badge-cancelled { 
    background: var(--danger-light); 
    color: var(--danger); 
}
.badge-raw {
    background: #fef3c7;
    color: #92400e;
}
.badge-semi {
    background: #e0e7ff;
    color: #4338ca;
}
.badge-finished {
    background: var(--success-light);
    color: var(--success);
}
.badge-active {
    background: var(--success-light);
    color: var(--success);
}
.badge-inactive {
    background: var(--danger-light);
    color: var(--danger);
}
.badge-green {
    background: var(--success-light);
    color: var(--success);
}
.badge-red {
    background: var(--danger-light);
    color: var(--danger);
}
.badge-orange {
    background: #fef3c7;
    color: #92400e;
}
.badge-teal {
    background: #ccfbf1;
    color: #0d9488;
}
.badge-blue {
    background: var(--info-light);
    color: var(--info);
}
.badge-secondary {
    background: var(--gray-200);
    color: var(--gray-600);
}
.badge-open {
    background: var(--success-light);
    color: var(--success);
}


/* ==================== MODALS ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px) scale(0.95);
    transition: var(--transition);
    box-shadow: var(--shadow-xl);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-close {
    background: var(--gray-100);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--gray-50);
}

/* ==================== LOADING & SPINNERS ==================== */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: currentColor;
    animation: spin 0.8s linear infinite;
}

.spinner-dark {
    border-color: var(--gray-300);
    border-top-color: var(--primary);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* ==================== EMPTY STATES ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--gray-300);
}

.empty-state h4 {
    font-size: 1.1rem;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* ==================== FILTERS BAR ==================== */
.filters-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters-bar .form-group {
    margin: 0;
    min-width: 160px;
}

.filters-bar .form-group label {
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.filters-bar .form-control {
    padding: 10px 14px;
    font-size: 0.9rem;
}

/* ==================== QUICK ACTIONS ==================== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    color: var(--gray-700);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.quick-action-btn i {
    width: 40px;
    height: 40px;
    background: var(--primary-50);
    color: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
}

.quick-action-btn:hover {
    border-color: var(--primary);
    background: var(--primary-50);
}

.quick-action-btn:hover i {
    background: var(--primary);
    color: var(--white);
}

/* ==================== TOOLTIPS ==================== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: var(--gray-900);
    color: var(--white);
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    margin-bottom: 8px;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ==================== PROGRESS BAR ==================== */
.progress {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-bar.success { background: linear-gradient(90deg, var(--success), #34d399); }
.progress-bar.warning { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.progress-bar.danger { background: linear-gradient(90deg, var(--danger), #f87171); }

/* ==================== RESPONSIVE ==================== */

/* Mobile Menu Toggle Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 44px;
    height: 44px;
    background: var(--white);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--gray-700);
    transition: var(--transition);
}

.mobile-menu-btn:hover {
    background: var(--gray-100);
}

.mobile-menu-btn.active {
    background: var(--primary);
    color: var(--white);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Don't block clicks when invisible */
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto; /* Only block clicks when visible */
}

/* Large Tablets (1024px and below) */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding: 24px;
        padding-top: 72px;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small Tablets (768px and below) */
@media (max-width: 768px) {
    .auth-card {
        padding: 32px 24px;
        max-width: 100%;
        border-radius: var(--radius-lg);
    }
    
    .auth-logo .logo-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
    
    .auth-logo h1 {
        font-size: 1.5rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .main-content {
        padding: 16px;
        padding-top: 68px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .page-header .btn {
        width: 100%;
        justify-content: center;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-card .stat-value {
        font-size: 1.75rem;
    }
    
    .filters-bar {
        flex-direction: column;
    }
    
    .filters-bar .form-group {
        width: 100%;
        min-width: auto;
    }
    
    .card {
        border-radius: var(--radius);
        margin-bottom: 16px;
    }
    
    .card-header {
        padding: 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .modal {
        margin: 10px;
        max-height: calc(100vh - 20px);
        border-radius: var(--radius-md);
    }
    
    .modal-header {
        padding: 16px 20px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 16px 20px;
    }
    
    .modal-footer {
        padding: 16px 20px;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
    }
    
    /* Table responsive - horizontal scroll */
    .table-responsive {
        margin: 0 -16px;
        padding: 0 16px;
    }
    
    table {
        min-width: 600px;
    }
    
    th, td {
        padding: 12px;
        font-size: 0.85rem;
    }
    
    /* Buttons - ensure minimum touch target size */
    .btn {
        padding: 12px 18px;
        font-size: 0.9rem;
        min-height: 44px; /* Apple's recommended touch target */
    }
    
    .btn-sm {
        padding: 10px 14px;
        font-size: 0.85rem;
        min-height: 40px;
    }
}

/* Mobile Phones (480px and below) */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .auth-container {
        padding: 12px;
    }
    
    .auth-card {
        padding: 24px 20px;
    }
    
    .auth-tabs {
        margin-bottom: 24px;
    }
    
    .auth-tab {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    .main-content {
        padding: 12px;
        padding-top: 64px;
    }
    
    .page-title {
        font-size: 1.35rem;
    }
    
    .mobile-menu-btn {
        top: 12px;
        left: 12px;
        width: 40px;
        height: 40px;
    }
    
    .sidebar-header {
        padding: 20px;
    }
    
    .sidebar-header h2 {
        font-size: 1.1rem;
    }
    
    .nav-link {
        padding: 14px 20px;
        font-size: 0.95rem;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-card .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
    
    .card-header {
        padding: 14px;
    }
    
    .card-body {
        padding: 14px;
    }
    
    .form-control {
        padding: 10px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    select.form-control {
        font-size: 16px;
    }
    
    .badge {
        padding: 4px 10px;
        font-size: 0.7rem;
    }
    
    /* Toast on mobile */
    #toast-container {
        left: 12px;
        right: 12px;
        top: 12px;
        max-width: none;
    }
    
    .toast {
        padding: 12px;
    }
    
    .toast-message {
        font-size: 0.9rem;
    }
}

/* Landscape mode on phones */
@media (max-width: 768px) and (orientation: landscape) {
    .auth-container {
        padding: 16px;
    }
    
    .auth-card {
        max-width: 500px;
        padding: 24px;
    }
    
    .modal {
        max-height: 85vh;
    }
    
    .main-content {
        padding-top: 60px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
    }
    
    .nav-link {
        min-height: 48px;
    }
    
    .form-control {
        min-height: 44px;
    }
    
    .modal-close {
        width: 44px;
        height: 44px;
    }
    
    /* Larger touch targets for table actions */
    td .btn-ghost {
        min-width: 40px;
        min-height: 40px;
    }
    
    /* Remove hover effects on touch devices */
    .stat-card:hover {
        transform: none;
    }
    
    .quick-action-btn:hover {
        border-color: var(--gray-200);
        background: var(--white);
    }
    
    .quick-action-btn:hover i {
        background: var(--primary-50);
        color: var(--primary);
    }
    
    /* Active states for touch */
    .btn:active {
        transform: scale(0.98);
    }
    
    .stat-card:active {
        transform: scale(0.98);
    }
    
    .nav-link:active {
        background: rgba(255,255,255,0.1);
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .sidebar-header .logo-icon,
    .auth-logo .logo-icon {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .mobile-menu-btn,
    .sidebar-overlay,
    .btn,
    .modal-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease;
}

.animate-slide-up {
    animation: slideUp 0.4s ease;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
}

/* ==================== UTILITIES ==================== */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--accent) !important; }
.text-muted { color: var(--gray-500) !important; }

.bg-primary { background: var(--primary) !important; }
.bg-success { background: var(--success) !important; }
.bg-danger { background: var(--danger) !important; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.text-center { text-align: center; }
.text-right { text-align: right; }

.font-bold { font-weight: 600; }
.font-normal { font-weight: 400; }


/* ==================== TOAST NOTIFICATIONS ==================== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    border-left: 4px solid var(--gray-400);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    border-left-color: var(--success);
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-error .toast-icon {
    color: var(--danger);
}

.toast-warning {
    border-left-color: var(--warning);
}

.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-info {
    border-left-color: var(--info);
}

.toast-info .toast-icon {
    color: var(--info);
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-message {
    font-size: 0.95rem;
    color: var(--gray-800);
    line-height: 1.5;
}

.toast-close {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    margin: -4px -4px -4px 0;
    font-size: 0.9rem;
    transition: color 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--gray-600);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gray-200);
}

.toast-progress-bar {
    height: 100%;
    background: currentColor;
    animation: toast-progress linear forwards;
    opacity: 0.3;
}

.toast-success .toast-progress-bar {
    background: var(--success);
}

.toast-error .toast-progress-bar {
    background: var(--danger);
}

.toast-warning .toast-progress-bar {
    background: var(--warning);
}

.toast-info .toast-progress-bar {
    background: var(--info);
}

@keyframes toast-progress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Mobile responsive */
@media (max-width: 480px) {
    #toast-container {
        left: 12px;
        right: 12px;
        max-width: none;
    }
}

/* ==================== GLOBAL MOBILE CARD STYLES ==================== */

/* Skeleton Loading Animation */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    border-left: 4px solid var(--gray-300);
}

/* Desktop/Mobile View Toggle */
@media (max-width: 768px) {
    .desktop-view, .desktop-table { display: none !important; }
    .mobile-view, .mobile-cards { display: block !important; }
}

@media (min-width: 769px) {
    .desktop-view, .desktop-table { display: block !important; }
    .mobile-view, .mobile-cards { display: none !important; }
}

/* Generic Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* Clickable Table Rows */
tr[onclick] {
    cursor: pointer;
}

tr[onclick]:hover td {
    background: var(--primary-50);
}

/* Touch-friendly improvements */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
    }
    
    .btn-sm {
        min-height: 38px;
        padding: 8px 14px;
    }
    
    .form-control {
        min-height: 44px;
    }
    
    select.form-control {
        min-height: 44px;
    }
}
