/* ========== App Layout ========== */
.invoicegen-app {
    display: flex;
    min-height: 100vh;
}

/* ========== Loading ========== */
.app-loading {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 999;
}

.app-loading.hidden {
    display: none;
}

.loading-logo {
    width: 60px;
    height: 60px;
}

.loading-text {
    color: var(--text2);
}

/* ========== Sidebar - Desktop ========== */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.logo svg {
    width: 28px;
    height: 28px;
}

.nav-btn {
    padding: 12px 14px;
    border: none;
    background: transparent;
    color: #ffffff;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
    display: block;
}

.nav-btn:hover,
.nav-btn.active {
    background: var(--accent);
    color: #fff;
}

/* ========== Main Content ========== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ========== Header ========== */
.header {
    padding: 14px 20px;
    background: var(--header-bg);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.header h1 {
    font-size: 18px;
    color: #fff;
    margin: 0;
    flex: 1;
    min-width: 80px;
}

#mobileMenuBtn {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
}

.business-switcher {
    display: flex;
    gap: 8px;
}

.search-box {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
}

.search-box::placeholder {
    color: #ffffff;
}

.search-box option {
    background: var(--bg2);
    color: var(--text);
}

/* ========== Unified Page Header ========== */
.page-header {
    background: var(--header-bg);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 100;
}

.page-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
}

.page-header .logo img {
    height: 32px;
    width: auto;
    border-radius: 6px;
}

.page-header nav {
    display: flex;
    gap: 16px;
    align-items: center;
}

.page-header nav a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
    font-weight: 500;
}

.page-header nav a:hover,
.page-header nav a.active {
    color: #fff;
}

.page-header nav .btn-outline {
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
}

.page-header nav .btn-outline:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }
}

.content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

@media (min-width: 1200px) {
    .sidebar {
        width: 240px;
    }

    .content {
        padding: 30px;
    }

    .stats {
        grid-template-columns: repeat(4, 1fr);
    }
}



/* Sales & Profit Analysis Header */
.sales-analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.chart-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 600px) {
    .sales-analysis-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .chart-controls .btn {
        flex: 1;
        text-align: center;
        min-width: 80px;
        padding: 8px 4px;
        font-size: 13px;
    }
}

/* Contact Page Grid */
.contact-grid {
    margin-top: 40px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 600px) {
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .chart-controls {
        margin-bottom: 15px;
        /* Prevent collision with chart */
    }
}

/* Responsive Table */
.table-responsive {
    width: 100%;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .table-responsive {
        overflow-x: hidden;
        /* No scrolling needed with vertical cards */
    }
}

.table-responsive table {
    width: 100%;
}

/* Let cards be cards – no forced table layout on mobile */

/* ========== App Footer (Force Specificity) ========== */
body .invoicegen-app .app-footer {
    background: #000000 !important;
    border-top: 1px solid #1a1a1a !important;
    padding: 16px 24px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.app-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #6366f1, transparent);
    opacity: 0.5;
}

.app-footer .footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 16px;
}

body .invoicegen-app .app-footer .footer-left,
body .invoicegen-app .app-footer .footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #ffffff !important;
}

body .invoicegen-app .app-footer .footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffffff !important;
    font-weight: 600;
    font-size: 14px;
}

.app-footer .footer-brand svg {
    filter: drop-shadow(0 0 4px rgba(99, 102, 241, 0.4));
}

body .invoicegen-app .app-footer .footer-separator {
    color: #ffffff !important;
}

body .invoicegen-app .app-footer .footer-copyright {
    color: #ffffff !important;
}

.app-footer .footer-version {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #ffffff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}



.app-footer .developer-link {
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
}

.app-footer .developer-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    transition: width 0.3s ease;
}

.app-footer .developer-link:hover {
    color: #ffffff;
}

.app-footer .developer-link:hover::after {
    width: 100%;
}



/* Footer Mobile */
@media (max-width: 768px) {
    .app-footer {
        padding: 14px 16px;
    }

    .app-footer .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .app-footer .footer-left,
    .app-footer .footer-right {
        flex-wrap: wrap;
        justify-content: center;
    }

    .app-footer .footer-separator {
        display: none;
    }
}