/**
 * Financial CRM - Admin Layout CSS
 * CSS thuần, responsive cơ bản
 */

/* ========== Reset & Base ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    background: #e8ecf1;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    color: #c7254e;
}

/* ========== Topbar ========== */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #1e293b;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.topbar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    margin-left: 10px;
    letter-spacing: 0.5px;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user {
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    display: none;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ========== Sidebar ========== */
.sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 240px;
    background: #1e293b;
    color: #94a3b8;
    overflow-y: auto;
    z-index: 900;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 16px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
    font-size: 1.6rem;
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e2e8f0;
}

.sidebar-nav {
    padding: 12px 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.92rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    text-decoration: none;
}

.sidebar-link.active {
    background: rgba(37, 99, 235, 0.15);
    color: #60a5fa;
    border-left-color: #3b82f6;
    font-weight: 600;
}

.sidebar-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: #475569;
    font-size: 0.8rem;
}

/* ========== App Wrapper & Main ========== */
.app-wrapper {
    display: flex;
    padding-top: 56px;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 28px;
    min-height: calc(100vh - 56px);
}

/* ========== Breadcrumb ========== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 8px;
}

.breadcrumb a {
    color: #64748b;
}

.breadcrumb a:hover {
    color: #2563eb;
}

.breadcrumb-sep {
    color: #cbd5e1;
}

/* ========== Page Title ========== */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 6px;
}

.page-desc {
    color: #64748b;
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* ========== Stat Cards ========== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-card-icon.revenue {
    background: rgba(16, 185, 129, 0.1);
}

.stat-card-icon.expense {
    background: rgba(239, 68, 68, 0.1);
}

.stat-card-icon.profit {
    background: rgba(245, 158, 11, 0.1);
}

.stat-card-icon.margin {
    background: rgba(99, 102, 241, 0.1);
}

.stat-card-body {
    flex: 1;
}

.stat-card-label {
    font-size: 0.82rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-card-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.stat-card-note {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-top: 4px;
}

/* ========== Chart Row ========== */
.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-box {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.chart-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
}

.chart-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.chart-placeholder {
    padding: 60px 20px;
    text-align: center;
    color: #94a3b8;
}

.chart-placeholder .placeholder-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 10px;
}

.chart-placeholder p {
    font-size: 0.9rem;
}

/* ========== Table Box ========== */
.table-box {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    margin-bottom: 24px;
}

.table-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
}

.table-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.82rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 2px solid #e2e8f0;
}

.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
    color: #334155;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ========== Badges ========== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-success {
    background: #dcfce7;
    color: #16a34a;
}

.badge-danger {
    background: #fee2e2;
    color: #dc2626;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.badge-primary {
    background: #dbeafe;
    color: #1d4ed8;
}

/* ========== Primary Row Highlight ========== */
.row-primary {
    background: #eff6ff !important;
    border-left: 3px solid #3b82f6;
}

.action-cell {
    white-space: nowrap;
}


/* ========== Info Box ========== */
.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.info-box h4 {
    font-size: 0.95rem;
    color: #1e40af;
    margin-bottom: 8px;
}

.info-box ul {
    padding-left: 20px;
    color: #3b82f6;
}

.info-box li {
    margin-bottom: 4px;
    font-size: 0.88rem;
    color: #1e40af;
}

/* ========== Buttons ========== */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    opacity: 0.85;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-outline {
    background: #fff;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.btn-outline:hover {
    background: #f1f5f9;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.82rem;
}

.btn-xs {
    padding: 3px 10px;
    font-size: 0.78rem;
    border-radius: 4px;
}

/* ========== Page Title Row ========== */
.page-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ========== Form Card ========== */
.form-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    margin-bottom: 24px;
    overflow: hidden;
}

.form-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 0 4px;
}

.btn-close:hover {
    color: #dc2626;
}

.form-card-body {
    padding: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.required {
    color: #dc2626;
}

.form-control {
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #334155;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.form-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 3px;
}

/* ========== Upload Area ========== */
.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
    transition: all 0.2s;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: #3b82f6;
    background: #eff6ff;
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.upload-btn {
    margin-top: 10px;
    cursor: pointer;
}

/* ========== Alerts ========== */
.alert {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.88rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #e0f2fe;
    color: #075985;
    border: 1px solid #bae6fd;
}

/* ========== Utilities ========== */
.text-center {
    text-align: center;
}

.text-muted {
    color: #94a3b8;
}

.text-danger {
    color: #dc2626;
    font-size: 0.8rem;
    display: block;
    margin-top: 4px;
}

.text-positive {
    color: #16a34a;
    font-weight: 600;
}

.text-negative {
    color: #dc2626;
    font-weight: 600;
}

/* ========== Info Box ========== */
.info-box {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 12px 18px;
    color: #0c4a6e;
    font-size: 0.9rem;
}

.stat-card-icon.expense {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #dc2626;
}

/* ========== Sidebar Overlay (Mobile) ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 899;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .stat-cards {
        grid-template-columns: 1fr;
    }

    .topbar-brand {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .data-table {
        font-size: 0.82rem;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 8px 10px;
    }
}