/* SME Invoice Manager - Responsive Design */
:root {
    --primary: #1a3a4a;
    --primary-dark: #0f2a36;
    --accent: #20b2aa;
    --accent-hover: #1a9b94;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #212529;
    --sidebar-width: 260px;
    --header-height: 60px;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0f4f8;
    color: #333;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ========== AUTH PAGES ========== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a3a4a 0%, #0f2a36 50%, #20b2aa 100%);
    padding: 20px;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.auth-card .logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-card .logo h1 {
    font-size: 1.6rem;
    color: var(--primary);
    font-weight: 700;
}

.auth-card .logo p {
    color: #6c757d;
    font-size: 0.9rem;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.4rem;
    color: #444;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #dee2e6;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(32, 178, 170, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

.btn-block {
    width: 100%;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #212529; }

.alert {
    padding: 0.9rem 1.1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ========== LAYOUT ========== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    padding: 0.5rem 1.5rem 0.3rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.5);
    margin-top: 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-left-color: var(--accent);
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--primary);
}

.page-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* ========== CARDS & STATS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.info { border-left-color: var(--info); }

.stat-card .label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.3rem;
}

.stat-card .value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .sub {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.25rem;
}

.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary);
}

.card-body {
    padding: 1.25rem 1.5rem;
}

/* ========== TABLES ========== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

table th, table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

table th {
    background: #f8fafc;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

table tbody tr:hover {
    background: #f8fafc;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e2e3e5; color: #383d41; }
.badge-primary { background: #cce5ff; color: #004085; }

/* ========== QUICK ACTIONS ========== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.quick-btn {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
    color: var(--primary);
}

.quick-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    color: var(--accent);
}

.quick-btn i {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    display: block;
    color: var(--accent);
}

.quick-btn span {
    font-size: 0.85rem;
    font-weight: 600;
}

/* ========== FORMS ========== */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #888;
}

.empty-state i {
    font-size: 3.5rem;
    color: #ccc;
    margin-bottom: 1rem;
}

.empty-state p {
    margin-bottom: 1.25rem;
}

/* ========== MOBILE ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .menu-toggle {
        display: block;
    }
}

@media (max-width: 576px) {
    .content-area {
        padding: 1rem;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .stat-card .value {
        font-size: 1.3rem;
    }
    .auth-card {
        padding: 1.75rem;
    }
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ========== PRINT ========== */
@media print {
    .sidebar, .topbar, .menu-toggle, .no-print {
        display: none !important;
    }
    .main-content {
        margin-left: 0;
    }
}

/* ===== Enhanced responsive ===== */
html { -webkit-text-size-adjust: 100%; }
img, video, canvas { max-width: 100%; height: auto; }
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 0.75rem !important; }
  .quick-actions { grid-template-columns: 1fr 1fr !important; }
  .card-header { flex-direction: column; align-items: flex-start !important; }
  .topbar { padding: 0 0.75rem; }
  .content-area { padding: 0.85rem !important; }
  table th, table td { padding: 0.55rem 0.5rem !important; font-size: 0.82rem !important; }
  .btn { min-height: 40px; }
  .form-control { font-size: 16px !important; /* prevent iOS zoom */ }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .quick-actions { grid-template-columns: 1fr !important; }
}

/* POS thermal print helper */
@media print {
  .sidebar, .topbar, .menu-toggle, .no-print, .sidebar-overlay, .quick-actions { display: none !important; }
  .main-content { margin-left: 0 !important; width: 100% !important; }
  .content-area { padding: 0 !important; }
  .card { box-shadow: none !important; border: none !important; }
  body { background: #fff !important; }
}
