/* =============================================
   Box Cricket Manager v3 - Clean Sports Theme
   ============================================= */

:root {
    --primary: #2563eb;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;
    --dark: #1e293b;
    --gray: #64748b;
    --gray-light: #f1f5f9;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; }

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
    overflow-y: scroll;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f0f4f8;
    color: var(--dark);
    font-size: 0.925rem;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Login Page ---- */
.login-container {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    min-height: 100vh;
    padding: 1rem;
}
.login-card { border-radius: 1rem !important; }
.login-icon {
    width: 80px; height: 80px; border-radius: 50%;
    background: var(--primary-light);
    display: inline-flex; align-items: center; justify-content: center;
}
.login-container .input-group {
    align-items: center;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.login-container .input-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.login-container .input-group .input-group-text {
    border: none !important;
    min-width: 44px;
    justify-content: center;
    align-items: center;
}
.login-container .input-group .form-control {
    border: none !important;
    padding-left: 0.75rem;
    min-height: 44px;
    margin-left: 0;
}
.login-container .input-group .form-control:focus {
    box-shadow: none;
}
.login-container .mb-3 { margin-bottom: 1rem !important; }
.login-container .mb-4 { margin-bottom: 1.25rem !important; }

/* ---- Sidebar ---- */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh; height: 100dvh;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    z-index: 1040; transition: transform 0.3s ease;
    display: flex; flex-direction: column;
    overflow: hidden;
}

.sidebar-brand {
    padding: 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.sidebar-brand h5 { color: #fff; margin: 0; font-weight: 700; font-size: 1.1rem; }
.sidebar-brand small { color: rgba(255,255,255,0.5); font-size: 0.75rem; }

.sidebar-nav {
    padding: 0.75rem 0; flex: 1 1 0; min-height: 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sidebar-nav .nav-label {
    display: block; padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px;
    color: rgba(255,255,255,0.35); font-weight: 600;
}

.sidebar-nav .nav-link {
    display: flex; align-items: center; padding: 0.6rem 1.25rem;
    color: rgba(255,255,255,0.7); font-size: 0.875rem; font-weight: 500;
    transition: all 0.2s; text-decoration: none;
}
.sidebar-nav .nav-link i { width: 20px; margin-right: 0.75rem; text-align: center; font-size: 1rem; }
.sidebar-nav .nav-link:hover, .sidebar-nav .nav-link.active { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav .nav-link.active { border-left: 3px solid var(--primary); background: rgba(37,99,235,0.15); }

.sidebar-user {
    padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0; background: rgba(0,0,0,0.2);
}
.sidebar-user .user-name { color: #fff; font-weight: 600; font-size: 0.85rem; }
.sidebar-user .user-role { color: rgba(255,255,255,0.5); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    overflow-x: hidden;
    overflow-y: visible;
}

/* ---- Top Navbar ---- */
.top-navbar {
    background: #fff; padding: 0.75rem 1.5rem; border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 1030;
}
.top-navbar .page-title { font-weight: 700; font-size: 1.15rem; color: var(--dark); margin: 0; }

.hamburger-btn {
    display: none; border: none; background: none;
    font-size: 1.4rem; color: var(--dark); padding: 0.25rem; cursor: pointer;
}

/* ---- Content Area ---- */
.content-area { padding: 1.25rem 1.5rem 2rem; overflow-x: hidden; overflow-y: visible; }

/* ---- Dashboard Cards ---- */
.stat-card {
    border: none; border-radius: 0.875rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    transition: transform 0.15s, box-shadow 0.15s; overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-card .card-body { padding: 1.15rem 1.25rem; }

.stat-card .stat-icon {
    width: 46px; height: 46px; border-radius: 0.75rem;
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.stat-card .stat-label {
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--gray); margin-bottom: 0.25rem;
}
.stat-card .stat-value { font-size: 1.35rem; font-weight: 700; color: var(--dark); line-height: 1.2; }

.icon-blue { background: var(--primary-light); color: var(--primary); }
.icon-green { background: var(--success-light); color: var(--success); }
.icon-yellow { background: var(--warning-light); color: var(--warning); }
.icon-red { background: var(--danger-light); color: var(--danger); }
.icon-cyan { background: var(--info-light); color: var(--info); }

/* ---- Quick Action Buttons ---- */
.quick-btn {
    border-radius: 0.75rem; padding: 0.75rem 1.25rem; font-weight: 600;
    font-size: 0.875rem; border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: inline-flex; align-items: center; gap: 0.5rem; transition: all 0.2s;
}
.quick-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.12); }

/* ---- Cards / Panels ---- */
.panel-card {
    border: none; border-radius: 0.875rem; box-shadow: 0 1px 3px rgba(0,0,0,0.06); background: #fff;
    overflow: visible;
}
.panel-card .card-header {
    background: transparent; border-bottom: 1px solid #f1f5f9;
    padding: 1rem 1.25rem; font-weight: 700; font-size: 0.95rem;
}
.panel-card .card-body { padding: 1.25rem; }

/* ---- Tables ---- */
.table-responsive {
    border-radius: 0.75rem;
    display: block;
    width: 100%;
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
}
.data-table { margin-bottom: 0; font-size: 0.85rem; min-width: 600px; table-layout: auto; }
.data-table thead th {
    background: var(--gray-light); font-weight: 600; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray);
    border-bottom: none; padding: 0.75rem 0.75rem; white-space: nowrap;
}
.data-table tbody td { padding: 0.65rem 0.75rem; vertical-align: middle; border-color: #f1f5f9; white-space: nowrap; }
.data-table tbody tr:hover { background: #f8fafc; }

/* ---- Badges ---- */
.badge-status {
    padding: 0.35rem 0.65rem; border-radius: 2rem; font-size: 0.7rem;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
    display: inline-block;
}
.badge-full { background: var(--success-light); color: var(--success); }
.badge-partial { background: var(--warning-light); color: var(--warning); }
.badge-pending { background: var(--danger-light); color: var(--danger); }
.badge-cash { background: #f0fdf4; color: #15803d; }
.badge-online { background: #eff6ff; color: #2563eb; }
.badge-mcga { background: #dbeafe; color: #1d4ed8; }
.badge-mcgb { background: #fce7f3; color: #be185d; }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-inactive { background: var(--danger-light); color: var(--danger); }

/* ---- Approval Status Badges ---- */
.badge-approval-pending { background: #f1f5f9; color: #64748b; }
.badge-approval-received { background: var(--warning-light); color: #b45309; }
.badge-approval-approved { background: var(--success-light); color: var(--success); }
.badge-approval-rejected { background: var(--danger-light); color: var(--danger); }

/* ---- Reconciliation Badges ---- */
.badge-recon-match { background: var(--success-light); color: var(--success); }
.badge-recon-missing { background: var(--danger-light); color: var(--danger); }
.badge-recon-extra { background: #dbeafe; color: #2563eb; }
.badge-recon-mismatch { background: var(--warning-light); color: #b45309; }
.badge-recon-slot { background: var(--info-light); color: var(--info); }

/* ---- Slot Badge ---- */
.slot-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #f0f9ff;
    color: #0369a1;
    border-radius: 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* ---- Forms ---- */
.form-control, .form-select {
    border-radius: 0.5rem; padding: 0.55rem 0.85rem;
    border-color: #e2e8f0; font-size: 0.875rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-label { font-weight: 600; font-size: 0.8rem; color: var(--gray); margin-bottom: 0.35rem; }

/* ---- Partner Cards ---- */
.partner-card {
    transition: transform 0.15s, box-shadow 0.15s;
}
.partner-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

/* ---- Change Diff ---- */
.change-diff {
    line-height: 1.6;
}

/* ---- Log Entry ---- */
.log-entry:hover {
    background: #f8fafc;
}

/* ---- Table row highlights ---- */
.table-warning-light {
    background-color: #fffbeb !important;
}
.table-warning-light:hover {
    background-color: #fef3c7 !important;
}
.table-danger-light {
    background-color: #fef2f2 !important;
}
.table-danger-light:hover {
    background-color: #fee2e2 !important;
}

/* ---- Mobile Overlay ---- */
.sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 1035;
}
.sidebar-overlay.show {
    display: block;
    touch-action: none;
    overscroll-behavior: contain;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; overflow-x: hidden; }
    .hamburger-btn { display: block; min-width: 44px; min-height: 44px; }
    .content-area { padding: 1rem; overflow-x: hidden; }
    .stat-card .stat-value { font-size: 1.15rem; }
    .stat-card .card-body { padding: 1rem; }
    .sidebar-nav .nav-link { min-height: 44px; padding: 0.75rem 1.25rem; }
    body.sidebar-open { overflow: hidden; }
    .table-responsive { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 575.98px) {
    .top-navbar { padding: 0.65rem 1rem; }
    .content-area { padding: 0.75rem; padding-bottom: 5rem; overflow-x: hidden; }
    .stat-card .stat-value { font-size: 1.05rem; }
    .data-table { min-width: 500px; }
    .data-table thead th { padding: 0.6rem 0.5rem; font-size: 0.7rem; }
    .data-table tbody td { padding: 0.5rem 0.5rem; font-size: 0.8rem; }
    .data-table .btn-sm {
        min-height: 44px;
        padding: 0.4rem 0.75rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .quick-btn { min-height: 44px; padding: 0.65rem 1rem; }
}

/* PWA standalone scroll fix */
@media (display-mode: standalone) {
    html, body { overflow-y: auto !important; height: auto !important; }
    .main-content { overflow-y: visible; }
    .content-area { overflow-x: hidden; }
    .table-responsive { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
}

/* ---- Misc ---- */
.text-truncate-2 {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cursor-pointer { cursor: pointer; }

.fade-in { animation: fadeIn 0.25s ease forwards; }
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---- Chart Container ---- */
.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
    min-height: 200px;
}

/* ---- PWA Install Banner ---- */
.pwa-install-banner {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 0.75rem 1.25rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1050;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
    animation: slideUp 0.3s ease;
}
.pwa-install-banner .btn { min-height: 44px; }

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Standalone mode: hide install banner, adjust safe areas */
@media (display-mode: standalone) {
    .pwa-install-banner { display: none !important; }
    .top-navbar { padding-top: calc(0.75rem + env(safe-area-inset-top, 0px)); position: sticky; top: 0; }
    .content-area { padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px)); }
}

/* Touch-friendly: prevent tap highlight delay on buttons */
@media (hover: none) and (pointer: coarse) {
    .btn, .quick-btn, .nav-link, .hamburger-btn {
        touch-action: manipulation;
    }
}

/* ---- Print styles ---- */
@media print {
    .sidebar, .top-navbar, .quick-btn, .no-print, .pwa-install-banner { display: none !important; }
    .main-content { margin-left: 0 !important; }
}

/* ---- Clickable payment rows ---- */
tr.payment-row:hover { background-color: rgba(13, 110, 253, 0.04) !important; }
tr[style*="cursor:pointer"]:hover { background-color: rgba(13, 110, 253, 0.04) !important; }

/* ---- btn-check label styles (radio toggle) ---- */
.btn-check:checked + .btn-outline-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-check:checked + .btn-outline-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
