/* ==========================================
   SIM Card Inventory System — Shared Styles
   Modern Dashboard Design
   ========================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy:       #0f172a;
    --navy-light: #1e293b;
    --blue:       #2563eb;
    --blue-hover: #1d4ed8;
    --green:      #10b981;
    --green-hover:#059669;
    --red:        #ef4444;
    --red-hover:  #dc2626;
    --orange:     #f59e0b;
    --gray-50:    #f8fafc;
    --gray-100:   #f1f5f9;
    --gray-200:   #e2e8f0;
    --gray-300:   #cbd5e1;
    --gray-400:   #94a3b8;
    --gray-500:   #64748b;
    --gray-600:   #475569;
    --gray-700:   #334155;
    --gray-800:   #1e293b;
    --gray-900:   #0f172a;
    --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
    --shadow:     0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --radius:     10px;
    --radius-lg:  14px;
    --transition: all 0.25s ease;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-700);
    line-height: 1.6;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ---------- Layout: Sidebar + Content ---------- */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--navy) 0%, #162033 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-brand {
    padding: 28px 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand h2 i {
    font-size: 22px;
    color: var(--blue);
}
.sidebar-brand p {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-300);
    transition: var(--transition);
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}
.sidebar-nav a.active {
    background: var(--blue);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37,99,235,0.35);
}
.sidebar-nav a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-400);
    transition: var(--transition);
}
.sidebar-footer a:hover {
    background: rgba(239,68,68,0.15);
    color: var(--red);
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    min-height: 100vh;
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}
.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.3px;
}
.page-header .subtitle {
    font-size: 13px;
    color: var(--gray-400);
    margin-top: 2px;
}

/* ---------- Stat Cards ---------- */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: var(--transition);
    border: 1px solid transparent;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--gray-200);
}
.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; color: var(--blue); }
.stat-icon.green  { background: #d1fae5; color: var(--green); }
.stat-icon.orange { background: #fef3c7; color: var(--orange); }
.stat-icon.red    { background: #fee2e2; color: var(--red); }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}
.stat-info p {
    font-size: 13px;
    color: var(--gray-400);
    margin-top: 4px;
    font-weight: 500;
}

/* ---------- Toolbar / Filter Bar ---------- */
.toolbar {
    background: #fff;
    padding: 16px 20px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.filter-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* ---------- Form Controls ---------- */
input[type="text"],
input[type="date"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    padding: 10px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-700);
    background: #fff;
    outline: none;
    transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
textarea { resize: vertical; }

/* ---------- Buttons ---------- */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--blue);  color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,0.25); }
.btn-primary:hover { background: var(--blue-hover); box-shadow: 0 4px 12px rgba(37,99,235,0.35); }

.btn-success   { background: var(--green); color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,0.25); }
.btn-success:hover { background: var(--green-hover); }

.btn-danger    { background: var(--red);   color: #fff; box-shadow: 0 2px 8px rgba(239,68,68,0.25); }
.btn-danger:hover  { background: var(--red-hover); }

.btn-secondary { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-200); box-shadow: none; }
.btn-secondary:hover { background: var(--gray-200); }

.btn-outline   { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-outline:hover { background: var(--blue); color: #fff; }

.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ---------- Table ---------- */
.table-container {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}
thead th {
    background: var(--navy-light);
    color: var(--gray-50);
    padding: 14px 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    position: sticky;
    top: 0;
}
tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
    white-space: nowrap;
}
tbody tr {
    cursor: pointer;
    transition: var(--transition);
}
tbody tr:hover {
    background: var(--gray-50);
}
tbody tr:last-child td {
    border-bottom: none;
}
.no-data {
    text-align: center;
    color: var(--gray-400);
    padding: 48px 20px !important;
    font-style: italic;
    font-size: 14px;
}

/* ---------- Telco Badges ---------- */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.badge-myevo       { background: #dbeafe; color: #1d4ed8; }
.badge-maxis       { background: #d1fae5; color: #047857; }
.badge-umobile     { background: #fef3c7; color: #b45309; }
.badge-celcomdigi  { background: #ede9fe; color: #6d28d9; }
.badge-celcom      { background: #e0e7ff; color: #4338ca; }
.badge-digi        { background: #fce7f3; color: #be185d; }
.badge-default     { background: var(--gray-200); color: var(--gray-600); }

/* ---------- Card (Generic) ---------- */
.card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px 28px;
    margin-bottom: 20px;
}
.card h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.card h2 i {
    color: var(--blue);
}

/* ---------- Info Grid (Details page) ---------- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.info-item .label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.info-item .value {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
}

/* ---------- Form Layout ---------- */
.form-container {
    max-width: 900px;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group.full-width {
    grid-column: span 2;
}
.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-group label i {
    color: var(--gray-400);
    font-size: 14px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
}
.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

/* ---------- Toast Notification ---------- */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: var(--green);
    color: #fff;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(16,185,129,0.35);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.4s ease, fadeOut 0.4s ease 2.6s forwards;
}
.toast.error {
    background: var(--red);
    box-shadow: 0 8px 24px rgba(239,68,68,0.35);
}
@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; pointer-events: none; }
}

/* ---------- Clickable Customer Link ---------- */
.customer-link {
    color: var(--blue);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.customer-link:hover {
    color: var(--blue-hover);
    text-decoration: underline;
}

/* ---------- Due Date Alarm ---------- */
.due-overdue {
    color: #dc2626 !important;
    font-weight: 700;
}
.due-urgent {
    color: #ea580c !important;
    font-weight: 700;
}
.due-warning {
    color: #d97706 !important;
    font-weight: 600;
}
.due-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin-left: 4px;
    vertical-align: middle;
}
.due-overdue .due-tag {
    background: #fef2f2;
    color: #dc2626;
    animation: pulse-red 1.5s infinite;
}
.due-urgent .due-tag {
    background: #fff7ed;
    color: #ea580c;
}
.due-warning .due-tag {
    background: #fefce8;
    color: #d97706;
}
@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Due tag in details page */
.due-tag-detail {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
}
.due-tag-detail.due-overdue { background: #fef2f2; }
.due-tag-detail.due-urgent  { background: #fff7ed; }
.due-tag-detail.due-warning { background: #fefce8; }

/* ---------- Status Badges ---------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}
.status-activated {
    background: #d1fae5;
    color: #047857;
}
.status-activated:hover { background: #a7f3d0; }
.status-terminated {
    background: #fee2e2;
    color: #dc2626;
}
.status-terminated:hover { background: #fecaca; }

/* ---------- Sidebar Year Section ---------- */
.sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-500);
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 20px 16px 6px;
    margin-top: 4px;
}
.sidebar-year-scroll {
    max-height: 170px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}
.sidebar-year-scroll::-webkit-scrollbar {
    width: 5px;
}
.sidebar-year-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}
.sidebar-year-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
.sidebar-year-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}
.sidebar-add-year {
    border: 1.5px dashed rgba(255,255,255,0.15) !important;
    justify-content: center;
    margin-top: 4px;
    font-size: 13px !important;
    color: var(--gray-500) !important;
}
.sidebar-add-year:hover {
    border-color: rgba(255,255,255,0.3) !important;
    color: #fff !important;
}

/* ---------- Year Grid ---------- */
.year-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.year-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gray-50);
    padding: 14px 18px;
    border-radius: 10px;
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}
.year-item:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow-sm);
}
.year-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}
.year-label i { color: var(--blue); }

/* ---------- Login Page Specific ---------- */
.login-page {
    background: linear-gradient(135deg, var(--navy) 0%, #1a365d 50%, var(--blue) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px;
    padding: 48px 40px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
    text-align: center;
}
.login-box .logo-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--blue), #7c3aed);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 32px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(37,99,235,0.3);
}
.login-box h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 6px;
}
.login-box .login-subtitle {
    font-size: 14px;
    color: var(--gray-400);
    margin-bottom: 32px;
}
.login-box .input-group {
    display: flex;
    align-items: center;
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: var(--transition);
}
.login-box .input-group:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.login-box .input-icon {
    width: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--gray-400);
    font-size: 16px;
    flex-shrink: 0;
}
.login-box .input-group input {
    width: 100%;
    padding: 14px 14px 14px 0;
    border: none;
    background: transparent;
    font-size: 15px;
    outline: none;
    color: var(--gray-700);
}
.login-box .btn-signin {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--blue), #4f46e5);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
    box-shadow: 0 4px 16px rgba(37,99,235,0.3);
}
.login-box .btn-signin:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37,99,235,0.4);
}
.login-box .error-message {
    color: var(--red);
    font-size: 13px;
    margin-top: 16px;
    display: none;
    font-weight: 600;
    background: #fef2f2;
    padding: 10px;
    border-radius: 8px;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 20px 16px;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-group.full-width {
        grid-column: span 1;
    }
    .stat-cards {
        grid-template-columns: 1fr 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .mobile-toggle {
        display: block !important;
    }
}
@media (max-width: 480px) {
    .stat-cards {
        grid-template-columns: 1fr;
    }
}

/* Mobile menu toggle (hidden on desktop) */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
}

/* ---------- Overlay for mobile sidebar ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 90;
}
.sidebar-overlay.show { display: block; }

/* ---------- Utilities ---------- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.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; }
.fw-bold { font-weight: 700; }
.text-muted { color: var(--gray-400); }
.text-sm { font-size: 13px; }
