:root {
    /* Color Palette - Premium & Modern */
    --primary-color: #2c3e50;
    /* Deep Midnight Blue */
    --primary-hover: #34495e;
    --secondary-color: #95a5a6;
    --accent-color: #f1c40f;
    /* Cheese Gold */
    --accent-hover: #f39c12;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --info-color: #3498db;

    /* Backgrounds */
    --bg-body: #f4f6f9;
    /* Light Gray-Blue Tint */
    --bg-card: #ffffff;
    --bg-input: #ffffff;

    /* Typography */
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;

    /* UI Elements */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 50px;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 15px 30px rgba(0, 0, 0, 0.15);

    --transition-base: all 0.25s ease;
}

body {
    background-color: var(--bg-body);
    font-family: var(--font-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

/* -------------------------------------------------- */
/* Utility Classes                                    */
/* -------------------------------------------------- */
.text-break-word {
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: pre-wrap;
}

/* -------------------------------------------------- */
/* Navbar                                             */
/* -------------------------------------------------- */
/* -------------------------------------------------- */
/* Navbar (Dark Glassmorphism)                        */
/* -------------------------------------------------- */
.navbar-glass {
    background: rgba(33, 37, 41, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 0;
    transition: all 0.3s ease;
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.5rem;
    color: #ffffff !important;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7) !important;
    padding: 0.6rem 1.25rem !important;
    border-radius: var(--radius-pill);
    transition: var(--transition-base);
    font-size: 0.95rem;
}

.navbar-nav .nav-link:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.1);
}

.navbar-nav .nav-link.active {
    background-color: var(--accent-color);
    color: var(--primary-color) !important;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.navbar-toggler {
    border: none;
    padding: 0.5rem;
    color: rgba(255,255,255,0.8);
    border-radius: 50%;
    background-color: rgba(255,255,255,0.05);
}

.navbar-toggler:focus {
    box-shadow: none;
    background-color: rgba(255,255,255,0.1);
    color: #fff;
}

/* Navbar CTA (Call to Action) - Desktop */
.nav-link.btn-cta {
    background: var(--accent-color) !important;
    color: var(--primary-color) !important;
    font-weight: 700 !important;
    border-radius: var(--radius-pill) !important;
    padding: 0.6rem 1.5rem !important;
    box-shadow: 0 4px 10px rgba(241, 196, 15, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    margin-left: 0.5rem;
}

.nav-link.btn-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(241, 196, 15, 0.4);
    background: var(--accent-hover) !important;
}

/* Mobile Navbar Improvements */
@media (max-width: 991px) {
    .navbar-collapse {
        background: rgba(33, 37, 41, 0.98);
        border-radius: var(--radius-md);
        padding: 1rem;
        margin-top: 0.5rem;
        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        border: 1px solid rgba(255,255,255,0.1);
    }

    .navbar-nav .nav-item {
        width: 100%;
        margin-bottom: 0.25rem;
    }

    .navbar-nav .nav-link {
        display: flex;
        align-items: center;
        width: 100%;
        padding: 0.8rem 1rem !important; /* Larger touch target */
        border-radius: var(--radius-sm);
        background: rgba(255,255,255,0.03);
    }
    
    .navbar-nav .nav-link:active {
        background: rgba(255,255,255,0.1);
        transform: scale(0.98);
    }

    .nav-link.btn-cta {
        margin-left: 0;
        margin-top: 0.5rem;
        justify-content: center;
        background: var(--accent-color) !important;
    }
}

/* Cards                                              */
/* -------------------------------------------------- */
.card {
    border: none;
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-modern {
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-lg);
}

.card-modern:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

/* Stat Cards */
.card-stat {
    border-left: 6px solid transparent;
}

.card-stat.success {
    border-left-color: var(--success-color);
}

.card-stat.warning {
    border-left-color: var(--accent-hover);
}

/* Client Cards */
.client-card {
    height: 100%;
    /* display: flex -> handled by bootstrap classes usually, but ensuring flex col */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border-top: 5px solid transparent;
    transition: var(--transition-base);
    position: relative;
}

.client-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.client-card.owing {
    border-top-color: var(--danger-color);
}

.client-card.paid {
    border-top-color: var(--success-color);
}

.client-card h5 a {
    color: var(--primary-color);
    font-weight: 700;
    transition: color 0.2s;
}

.client-card h5 a:hover {
    color: var(--primary-hover);
}

/* -------------------------------------------------- */
/* Buttons & Inputs                                   */
/* -------------------------------------------------- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    transition: var(--transition-base);
}

.btn-lg {
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 4px 6px rgba(44, 62, 80, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(44, 62, 80, 0.3);
}

/* Custom "Action" Buttons (often red or success) */
.btn-outline-danger {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-outline-danger:hover {
    background-color: var(--danger-color);
    color: #fff;
}

/* Form Controls */
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    padding: 0.7rem 1rem;
    border: 1px solid #e2e8f0;
    background-color: var(--bg-input);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(241, 196, 15, 0.15);
}

.search-container {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* -------------------------------------------------- */
/* Badges & Pills                                     */
/* -------------------------------------------------- */
.badge {
    border-radius: var(--radius-pill);
    padding: 0.5em 0.8em;
    font-weight: 600;
    letter-spacing: 0.3px;

}

.badge-status {
    font-size: 0.85rem;
}

/* -------------------------------------------------- */
/* Mobile Optimizations                               */
/* -------------------------------------------------- */
@media (max-width: 768px) {
    .navbar-custom {
        padding: 0.8rem 1rem;
    }

    .card-stat {
        margin-bottom: 0.5rem;
    }

    .search-container {
        padding: 1rem;
    }

    /* Mobile Optimization - Fitts' Law */
    .btn, .form-control, .form-select, .nav-link, .btn-financial {
        min-height: 48px; /* Recommended 48px for comfort */
        display: inline-flex;
        align-items: center;
    }
    
    /* Ensure full width actions in "Thumb Zone" */
    .btn-action-primary {
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }
}

/* -------------------------------------------------- */
/* New Components (Gravity Scan)                      */
/* -------------------------------------------------- */

/* Control Bar - Unified Action Strip */
.control-bar {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-base);
}

.control-bar:focus-within {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.8);
}

/* Seamless Inputs inside Control Bar */
.control-bar .form-control,
.control-bar .form-select {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
}

.control-bar .form-control:focus,
.control-bar .form-select:focus {
    box-shadow: none;
    background: rgba(244, 246, 249, 0.5);
    border-radius: var(--radius-pill);
}

.control-bar .input-group-text {
    background: transparent;
    border: none;
    color: var(--text-muted);
}

/* Vertical Divider for Desktop */
.control-divider {
    width: 1px;
    height: 30px;
    background-color: #e2e8f0;
    margin: 0 0.5rem;
    display: none;
    /* Hidden on mobile */
}

@media (min-width: 768px) {
    .control-divider {
        display: block;
    }

    .control-bar {
        flex-wrap: nowrap;
        padding: 0.4rem 0.6rem;
    }
}

/* Modern Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 46px;
    height: 24px;
    background-color: #e2e8f0;
    border-radius: 34px;
    transition: .3s;
    margin-right: 0.75rem;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: .3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input:checked+.toggle-slider {
    background-color: var(--danger-color);
    /* Warning/Debt Color */
}

input:checked+.toggle-slider:before {
    transform: translateX(22px);
}

.toggle-label {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.95rem;
}

input:checked~.toggle-label {
    color: var(--danger-color);
    font-weight: 600;
}

/* =========================================
   Phase 7: Financial Cards
   ========================================= */
.financial-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    padding: 1.5rem;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.financial-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.financial-card.owing {
    border-left: 5px solid var(--danger-color, #dc3545);
}

.financial-card.paid {
    border-left: 5px solid var(--success-color, #198754);
}

.client-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--dark-color, #212529);
    letter-spacing: -0.01em;
    margin-bottom: 0.25rem;
    text-decoration: none;
    display: block;
}

.client-name:hover {
    color: var(--primary-color, #0d6efd);
}

.client-nickname {
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: 500;
}

.balance-section {
    margin: 1.5rem 0;
}

.balance-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: #adb5bd;
    display: block;
    margin-bottom: 0.25rem;
}

.text-balance {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
}

.text-balance.text-danger {
    color: #dc3545 !important;
}

.text-balance.text-success {
    color: #198754 !important;
}

.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: auto;
}

.btn-financial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    cursor: pointer;
    position: relative;
    /* Ensure it sits above stretched-link */
    z-index: 2;
}

.btn-financial i {
    font-size: 1.1em;
    margin-right: 0.4rem;
}

.btn-financial.sale {
    background-color: #fff5f5;
    color: #dc3545;
}

.btn-financial.sale:hover {
    background-color: #ffe0e0;
    transform: translateY(-2px);
    color: #c82333;
}

.btn-financial.receive {
    background-color: #f0fff4;
    color: #198754;
}

.btn-financial.receive:hover {
    background-color: #d1e7dd;
    transform: translateY(-2px);
    color: #146c43;
}


/* =========================================
   Phase 8.5: Detail View Modernization
   ========================================= */

/* Transaction List (Bank Statement Style) */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.transaction-item {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    padding: 1.25rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    position: relative;
}

.transaction-item:hover {
    transform: translateX(4px);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    z-index: 1;
}

.transaction-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

.transaction-icon.sale {
    background-color: #fff5f5;
    color: #dc3545;
}

.transaction-icon.payment {
    background-color: #f0fff4;
    color: #198754;
}

.transaction-details {
    flex-grow: 1;
    min-width: 0;
    /* Truncation fix */
}

.transaction-date {
    font-size: 0.75rem;
    font-weight: 600;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
}

.transaction-desc {
    font-weight: 600;
    color: var(--dark-color);
    font-size: 1rem;
    margin-bottom: 0;
}

.transaction-amount {
    text-align: right;
    margin-left: 1rem;
}

.amount-display {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 1.1rem;
    display: block;
    line-height: 1.2;
}

.amount-display.debit {
    color: #dc3545;
}

.amount-display.credit {
    color: #198754;
}

.balance-display {
    font-size: 0.75rem;
    color: #adb5bd;
    font-weight: 500;
    display: block;
    margin-top: 2px;
}

/* History Cards */
.history-card {
    background: #f8f9fa;
    border: 1px dashed #dee2e6;
    border-radius: 16px;
    padding: 1.25rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-card:hover {
    background: #fff;
    border-color: var(--primary-color);
    border-style: solid;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.month-divider {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #adb5bd;
    letter-spacing: 1px;
    margin: 1.5rem 0 0.75rem 0.5rem;
}

/* Mobile Tweaks */
@media (max-width: 768px) {
    .transaction-item {
        padding: 1rem;
    }

    .transaction-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}
/* -------------------------------------------------- */
/* Phase 10: Modern Checkout (Vendas/Pagamentos)      */
/* -------------------------------------------------- */

.checkout-card {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.checkout-header {
    padding: 1.5rem;
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: relative;
}

.checkout-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
}

.checkout-header.sale::before { background-color: var(--danger-color); }
.checkout-header.payment::before { background-color: var(--success-color); }

.checkout-header .icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 1rem;
}

.checkout-header.sale .icon-box {
    background-color: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
}

.checkout-header.payment .icon-box {
    background-color: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
}

/* Cart Item List Style */
.cart-list-group {
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.cart-item {
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.cart-item:last-child { border-bottom: none; }
.cart-item:hover { background: #f8f9fa; }

.cart-item-info h6 { margin: 0; font-weight: 600; color: var(--text-main); }
.cart-item-info small { color: var(--text-muted); }

.cart-item-price {
    font-weight: 700;
    color: var(--text-main);
    text-align: right;
}

/* Large Inputs for Mobile */
.form-control-lg {
    font-size: 1.1rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
}

.btn-add-cart {
    height: 100%;
    border-radius: var(--radius-md);
    font-weight: 700;
}

/* -------------------------------------------------- */
/* Phase 11: Product Catalog (Grid & Cards)           */
/* -------------------------------------------------- */

.product-card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    height: 100%;
    background: #fff;
    position: relative;
    border: 1px solid rgba(0,0,0,0.03);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.product-icon-box {
    height: 120px;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #ffd700; /* Cheese Gold */
    position: relative;
}

.product-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.product-card:hover .product-actions { opacity: 1; }

/* In mobile, always show actions or put them elsewhere? 
   Let's keep them visible on hover for desktop, but maybe always visible or different on mobile.
   For simplicity: always visible but subtle on mobile */
@media (max-width: 768px) {
    .product-actions { opacity: 1; }
}

.product-body {
    padding: 1.25rem;
    text-align: center;
}

.product-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.unit-badge {
    background: rgba(0,0,0,0.05);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* -------------------------------------------------- */
/* Phase 12: Client Registration (Profile Style)      */
/* -------------------------------------------------- */

.profile-header-bg {
    height: 100px;
    background: linear-gradient(135deg, var(--dark-bg) 0%, #34495e 100%);
    position: relative;
}

.profile-avatar-container {
    position: relative;
    margin-top: -50px;
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid #fff;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--primary-color);
}

.form-section-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: var(--text-muted);
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* Enhancing Tom Select matches */
.ts-control {
    border: 1px solid #dee2e6;
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    font-size: 1.1rem;
    box-shadow: none !important;
}

.ts-dropdown {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: none;
    z-index: 1050;
}
