/* ========================================
   GMBSMS - Design System
   ======================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #818CF8;
    --secondary: #0EA5E9;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #6366F1;

    --bg-body: #F1F5F9;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1E293B;
    --bg-sidebar-hover: #334155;
    --bg-sidebar-active: #4F46E5;

    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --text-white: #FFFFFF;

    --border-color: #E2E8F0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);

    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --sidebar-width: 260px;
    --topbar-height: 64px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-white);
    z-index: 900;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

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

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-brand h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.sidebar-brand small {
    display: block;
    font-size: 0.7rem;
    opacity: 0.6;
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-section {
    padding: 0.5rem 1.5rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
    margin-top: 0.5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 400;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-white);
}

.sidebar-nav a.active {
    background: rgba(79, 70, 229, 0.15);
    color: var(--text-white);
    border-left-color: var(--primary);
    font-weight: 500;
}

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

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

.sidebar-user .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-info p {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-info small {
    font-size: 0.7rem;
    opacity: 0.6;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 800;
    box-shadow: var(--shadow-sm);
}

.topbar .page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.topbar .breadcrumb {
    margin: 0;
    font-size: 0.8rem;
}

.content-wrapper {
    flex: 1;
    padding: 1.5rem;
    padding-bottom: 2rem;
    position: relative;
    z-index: 1;
}

/* ========================================
   METRIC CARDS
   ======================================== */
.metric-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: box-shadow 0.2s ease;
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.metric-icon.primary { background: rgba(79,70,229,0.1); color: var(--primary); }
.metric-icon.success { background: rgba(16,185,129,0.1); color: var(--success); }
.metric-icon.warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.metric-icon.danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.metric-icon.info { background: rgba(14,165,233,0.1); color: var(--secondary); }

.metric-info h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.metric-info p {
    margin: 0.15rem 0 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ========================================
   CARDS & TABLES
   ======================================== */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    background: var(--bg-card);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.table {
    font-size: 0.85rem;
    margin-bottom: 0;
}

.table thead th {
    background: #F8FAFC;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-color: var(--border-color);
}

.table tbody tr:hover {
    background: #F8FAFC;
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.3em 0.7em;
    border-radius: 50rem;
    letter-spacing: 0.025em;
}

.badge-active, .badge-paid { background: rgba(16,185,129,0.1); color: #059669; }
.badge-expired, .badge-failed { background: rgba(239,68,68,0.1); color: #DC2626; }
.badge-pending { background: rgba(245,158,11,0.1); color: #D97706; }
.badge-cancelled { background: rgba(100,116,139,0.1); color: #475569; }
.badge-frozen { background: rgba(14,165,233,0.1); color: #0284C7; }
.badge-available { background: rgba(16,185,129,0.1); color: #059669; }
.badge-unavailable { background: rgba(239,68,68,0.1); color: #DC2626; }
.badge-refunded { background: rgba(99,102,241,0.1); color: #4F46E5; }
.badge-approved { background: rgba(16,185,129,0.1); color: #059669; }
.badge-rejected { background: rgba(239,68,68,0.1); color: #DC2626; }

/* ========================================
   BUTTONS
   ======================================== */
.btn { font-size: 0.85rem; font-weight: 500; border-radius: var(--radius); padding: 0.45rem 1rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-sm { font-size: 0.78rem; padding: 0.3rem 0.65rem; }

/* ========================================
   FORMS
   ======================================== */
.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

/* ========================================
   ALERTS
   ======================================== */
.alert {
    border-radius: var(--radius);
    font-size: 0.85rem;
    border: none;
    padding: 0.75rem 1rem;
}

.alert-success { background: rgba(16,185,129,0.1); color: #059669; }
.alert-danger, .alert-error { background: rgba(239,68,68,0.1); color: #DC2626; }
.alert-warning { background: rgba(245,158,11,0.1); color: #D97706; }
.alert-info { background: rgba(14,165,233,0.1); color: #0284C7; }

/* ========================================
   AUTH PAGES
   ======================================== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

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

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

.auth-card .auth-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.auth-card .auth-logo h4 {
    margin: 0;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.auth-card .auth-logo p {
    margin: 0.25rem 0 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ========================================
   PAGINATION
   ======================================== */
.pagination { 
    font-size: 0.8rem; 
    margin-bottom: 0 !important;
}
.page-link { 
    color: var(--primary); 
    border-color: var(--border-color); 
    padding: 0.35rem 0.7rem;
    position: relative;
    z-index: 1;
    font-size: 0.85rem;
    line-height: 1.5;
}
.page-link:hover { 
    color: var(--primary-dark); 
    background: rgba(79,70,229,0.05);
    z-index: 2;
}
.page-item.active .page-link { 
    background: var(--primary); 
    border-color: var(--primary);
    z-index: 3;
}
.page-item:first-child .page-link,
.page-item:last-child .page-link {
    font-size: 0.85rem;
}
/* Fix for overlapping pagination arrows */
.pagination .page-item {
    margin: 0 2px;
}
.pagination-wrapper {
    overflow-x: auto;
    padding: 0.5rem 0;
}
/* Ensure pagination nav has proper spacing */
nav[class*="pagination"] {
    margin-bottom: 1.5rem !important;
    clear: both;
}
/* Fix pagination text alignment */
nav .small.text-muted {
    line-height: 2.5;
    margin-bottom: 0 !important;
}

/* ========================================
   MODAL FIXES
   ======================================== */
.modal {
    z-index: 9999 !important;
}
.modal-backdrop {
    z-index: 9998 !important;
}
.modal-backdrop.show {
    opacity: 0.5;
}
.modal.show {
    display: block !important;
}
.modal-open {
    overflow: hidden;
}
.modal-open .sidebar {
    z-index: 900 !important;
}
.modal-open .sidebar-overlay {
    z-index: 0 !important;
    display: none !important;
}
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 3.5rem);
    z-index: 10000 !important;
}
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0,0,0,.2);
    border-radius: 0.5rem;
    outline: 0;
    z-index: 10001 !important;
}
.modal-header,
.modal-body,
.modal-footer {
    position: relative;
    z-index: 10002 !important;
}
.modal-body .form-control,
.modal-body .form-select,
.modal-body button,
.modal-footer button {
    position: relative;
    z-index: 10003 !important;
    pointer-events: auto !important;
}

/* ========================================
   UTILITIES
   ======================================== */
.text-peso { font-family: 'Inter', sans-serif; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }

.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

/* Prevent any element from having excessive z-index */
* {
    max-width: 100%;
}

/* Ensure content wrapper has proper padding at bottom */
.content-wrapper {
    padding-bottom: 2rem;
}

/* ========================================
   SIDEBAR TOGGLE (MOBILE)
   ======================================== */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.25rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}

.sidebar-overlay.show {
    z-index: 998;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
        z-index: 999;
    }
    .sidebar-overlay.show {
        display: block;
        z-index: 998;
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
}

/* ========================================
   CHART CONTAINER
   ======================================== */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}
