/* ==========================================================================
   STYLE SHEET - Monthly Credit Card & Debt Tracker
   Theme: Premium Deep Blue & Gold/Yellow (สีฟ้าเหลืองทอง)
   ========================================================================== */

/* --- Design Tokens & Variables --- */
:root {
    --bg-main: #060b19;
    --bg-sidebar: rgba(10, 18, 38, 0.7);
    --bg-card: rgba(17, 28, 54, 0.45);
    --bg-card-hover: rgba(22, 38, 74, 0.6);
    --border-color: rgba(218, 165, 32, 0.15); /* Translucent Gold */
    --border-color-blue: rgba(0, 180, 216, 0.2); /* Translucent Blue */
    
    /* Brand Colors */
    --color-blue-primary: #00b4d8;
    --color-blue-dark: #0077b6;
    --color-blue-light: #90e0ef;
    
    --color-gold-primary: #fbbf24;
    --color-gold-dark: #d97706;
    --color-gold-light: #fef08a;

    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #06b6d4;

    /* Text Colors */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #1e293b;
    
    /* Layout & Shadows */
    --sidebar-width: 280px;
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    --box-shadow-glow-blue: 0 0 15px rgba(0, 180, 216, 0.15);
    --box-shadow-glow-gold: 0 0 15px rgba(251, 191, 36, 0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Global Reset & Typography --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Prompt', 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 10% 20%, rgba(0, 119, 182, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(217, 119, 6, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(6, 11, 25, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(251, 191, 36, 0.3);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(251, 191, 36, 0.6);
}

/* --- Helper Utilities --- */
.hidden { display: none !important; }
.text-gold { color: var(--color-gold-primary) !important; }
.text-blue { color: var(--color-blue-primary) !important; }
.text-cyan { color: var(--color-info) !important; }
.text-success { color: var(--color-success) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-center { text-align: center; }
.cursor-pointer { cursor: pointer; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.mb-0 { margin-bottom: 0 !important; }

/* Glassmorphism styling */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Borders & Shadows */
.border-blue { border-color: var(--border-color-blue) !important; }
.border-gold { border-color: var(--border-color) !important; }
.border-cyan { border-color: rgba(6, 182, 212, 0.2) !important; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition-smooth);
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-blue-dark), var(--color-blue-primary));
    color: #fff;
    box-shadow: var(--box-shadow-glow-blue);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(0, 180, 216, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #0f766e, var(--color-success));
    color: #fff;
}
.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover {
    background: rgba(251, 191, 36, 0.08);
    border-color: var(--color-gold-primary);
    transform: translateY(-2px);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--color-danger);
    padding: 6px 12px;
    font-size: 12px;
}
.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--color-danger);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: var(--border-radius-sm);
}

.btn-block {
    width: 100%;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    transition: var(--transition-smooth);
}
.btn-close:hover {
    color: var(--color-gold-primary);
}

/* --- Form Fields & Inputs --- */
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrapper input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border-radius: var(--border-radius-md);
    background: rgba(10, 18, 38, 0.6);
    border: 1px solid rgba(218, 165, 32, 0.2);
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition-smooth);
}
.input-wrapper input:focus {
    outline: none;
    border-color: var(--color-gold-primary);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.2);
}
.input-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    color: var(--color-gold-primary);
}

.select-gold, select {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--border-radius-md);
    background: rgba(10, 18, 38, 0.7);
    border: 1px solid rgba(218, 165, 32, 0.25);
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.select-gold:focus, select:focus {
    outline: none;
    border-color: var(--color-gold-primary);
}

select option {
    color: #000000 !important;
    background-color: #ffffff !important;
}

input[type="number"], input[type="text"], input[type="month"], textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--border-radius-md);
    background: rgba(10, 18, 38, 0.7);
    border: 1px solid rgba(218, 165, 32, 0.25);
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition-smooth);
}
input[type="number"]:focus, input[type="text"]:focus, input[type="month"]:focus, textarea:focus {
    outline: none;
    border-color: var(--color-blue-primary);
}

/* ==========================================================================
   AUTHENTICATION SCREEN (LOCK SCREEN)
   ========================================================================== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 480px;
    padding: 40px;
    border-color: rgba(251, 191, 36, 0.3);
    box-shadow: var(--box-shadow-glow-gold);
    animation: fadeIn 0.5s ease-out;
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}
.logo-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}
.auth-logo h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--color-gold-primary);
}
.subtitle {
    font-size: 13px;
    margin-top: 4px;
}

.form-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.6;
}

.warning-text {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 11px;
    margin-top: 20px;
    line-height: 1.5;
    background: rgba(251, 191, 36, 0.05);
    padding: 10px;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(251, 191, 36, 0.15);
}

.error-text {
    font-size: 12px;
    color: var(--color-danger);
    margin-top: 6px;
}

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

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 10;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}
.brand-icon {
    width: 32px;
    height: 32px;
}
.sidebar-brand h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-gold-primary);
    letter-spacing: 1px;
}

.badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 20px;
    font-weight: 500;
}
.badge-gold {
    background: rgba(251, 191, 36, 0.15);
    color: var(--color-gold-primary);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    transition: var(--transition-smooth);
}
.menu-item:hover {
    color: var(--color-blue-primary);
    background: rgba(0, 180, 216, 0.08);
}
.menu-item.active {
    color: var(--color-gold-primary);
    background: rgba(251, 191, 36, 0.08);
    border-left: 3px solid var(--color-gold-primary);
    border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.user-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(16, 185, 129, 0.05);
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* --- Content Panel --- */
.content-area {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 30px;
    min-height: 100vh;
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    margin-bottom: 24px;
}
.header-title h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-gold-primary);
}
.header-title p {
    font-size: 13px;
    margin-top: 2px;
}

.month-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(10, 18, 38, 0.5);
    padding: 4px 10px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}
.month-selector select {
    border: none;
    background: transparent;
    padding: 6px;
    width: auto;
}

/* ==========================================================================
   METRIC SUMMARY CARDS
   ========================================================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    transition: var(--transition-smooth);
}
.metric-card:hover {
    transform: translateY(-4px);
    background: var(--bg-card-hover);
}

.metric-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius-md);
}
.bg-blue-tint { background: rgba(0, 180, 216, 0.15); }
.bg-gold-tint { background: rgba(251, 191, 36, 0.15); }
.bg-cyan-tint { background: rgba(6, 182, 212, 0.15); }

.metric-info {
    display: flex;
    flex-direction: column;
}
.metric-label {
    font-size: 13px;
    color: var(--text-muted);
}
.metric-value {
    font-size: 24px;
    font-weight: 700;
    margin: 4px 0;
}
.metric-trend {
    font-size: 11px;
}

/* ==========================================================================
   CHARTS & GRIDS
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.chart-container-card {
    padding: 24px;
}

.card-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 14px;
    margin-bottom: 18px;
}
.card-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main);
}

.chart-wrapper {
    height: 220px;
    position: relative;
    width: 100%;
}
.chart-wrapper-donut {
    height: 220px;
    position: relative;
    max-width: 220px;
    width: 100%;
}
.chart-wrapper-large {
    height: 280px;
    position: relative;
    width: 100%;
}

/* ==========================================================================
   TABLES & TRANSACTION TOOLBAR
   ========================================================================== */
.toolbar-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 24px;
    margin-bottom: 24px;
}

.toolbar-left, .toolbar-right, .excel-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-container-card {
    padding: 24px;
    margin-bottom: 30px;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13.5px;
}

.table th {
    padding: 14px 16px;
    font-weight: 500;
    color: var(--color-gold-primary);
    border-bottom: 2px solid rgba(251, 191, 36, 0.15);
    white-space: nowrap;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    white-space: nowrap;
}

.table tbody tr {
    transition: var(--transition-smooth);
}
.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Table statuses */
.status-pill {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 20px;
    font-weight: 500;
}
.status-paid {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-pending {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.status-partial {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Action buttons in tables */
.row-actions {
    display: flex;
    gap: 8px;
}
.btn-icon-only {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition-smooth);
    background: transparent;
}
.btn-edit {
    color: var(--color-blue-primary);
    border-color: rgba(0, 180, 216, 0.2);
}
.btn-edit:hover {
    background: rgba(0, 180, 216, 0.1);
    transform: scale(1.1);
}
.btn-delete {
    color: var(--color-danger);
    border-color: rgba(239, 68, 68, 0.2);
}
.btn-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

/* ==========================================================================
   REPORTS SECTION FILTERS
   ========================================================================== */
.filter-card {
    padding: 24px;
    margin-bottom: 24px;
}
.filter-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 500;
    color: var(--color-gold-primary);
    margin-bottom: 18px;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* ==========================================================================
   MODAL / POPUP
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(6, 11, 25, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.modal-card {
    width: 100%;
    max-width: 680px;
    padding: 30px;
    max-height: 90vh;
    overflow-y: auto;
    border-color: rgba(251, 191, 36, 0.35);
    box-shadow: var(--box-shadow-glow-gold);
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 14px;
    margin-bottom: 20px;
}
.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-gold-primary);
    font-size: 18px;
}

.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.required {
    color: var(--color-danger);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 20px;
    margin-top: 20px;
}

/* ==========================================================================
   ANIMATIONS & RESPONSIVENESS
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Media Queries & Responsive Layouts */
@media (max-width: 992px) {
    /* Tablet Styles */
    .sidebar {
        width: 80px;
        padding: 20px 10px;
        align-items: center;
    }
    .sidebar-brand h1, .sidebar-brand span, .menu-item span, .sidebar-footer {
        display: none;
    }
    .sidebar-brand {
        margin-bottom: 24px;
        justify-content: center;
    }
    .menu-item {
        justify-content: center;
        padding: 14px;
        border-radius: 50%;
        width: 48px;
        height: 48px;
    }
    .content-area {
        margin-left: 80px;
        padding: 24px;
    }
    body {
        font-size: 15px;
    }
}

@media (max-width: 768px) {
    /* Mobile Devices (iPhone 13 / SmartPhones) */
    .app-layout {
        flex-direction: column;
    }
    
    /* Bottom sticky navigation bar on mobile instead of sidebar */
    .sidebar {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        width: 100vw;
        height: 65px;
        flex-direction: row;
        justify-content: space-around;
        padding: 5px 15px;
        border-right: none;
        border-top: 1px solid var(--border-color);
        background: rgba(10, 18, 38, 0.95);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        z-index: 999;
    }
    .sidebar-brand {
        display: none !important;
    }
    .sidebar-menu {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        gap: 0;
        margin: 0;
    }
    .menu-item {
        flex-direction: column;
        gap: 4px;
        padding: 6px 12px;
        font-size: 11px;
        color: var(--text-muted);
        background: transparent !important;
        border: none !important;
        border-radius: var(--border-radius-sm);
        height: auto;
        width: auto;
    }
    .menu-item span {
        display: block !important;
        font-size: 10px;
    }
    .menu-item.active {
        color: var(--color-gold-primary);
    }
    .menu-item i {
        width: 20px;
        height: 20px;
    }
    .sidebar-footer {
        display: none !important;
    }
    
    .content-area {
        margin-left: 0;
        padding: 16px;
        padding-bottom: 90px; /* space for bottom nav bar */
    }
    
    .top-header {
        padding: 14px 18px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .header-actions {
        width: 100%;
    }
    
    .month-selector, .month-selector select {
        width: 100%;
        justify-content: center;
    }
    
    /* Optimize typography for small screen reading */
    body {
        font-size: 14px;
    }
    
    h2, #current-view-title {
        font-size: 18px !important;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .metric-card {
        padding: 16px;
    }
    
    .metric-value {
        font-size: 20px !important;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-group {
        margin-bottom: 14px;
    }
    
    .toolbar-card {
        flex-direction: column;
        align-items: stretch;
        padding: 14px 18px;
        gap: 10px;
    }
    
    .toolbar-left, .toolbar-right, .excel-actions {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }
    
    .btn {
        width: 100%;
        padding: 12px;
        font-size: 13px;
    }
    
    /* Make table scrollable on mobile */
    .table-container-card {
        padding: 14px;
    }
    .table th, .table td {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .modal-card {
        padding: 20px;
        max-height: 85vh;
    }
}
