/* Boleto Acqua Fácil - Premium CSS Design System */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --secondary: #0ea5e9;
    --accent: #22d3ee;
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #f8fafc;
    --border: #e2e8f0;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Sidebar Layout */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: width 0.25s ease, transform 0.25s ease;
    overflow: hidden;
}

/* Desktop collapsed state */
.sidebar.collapsed {
    width: 68px;
}

.sidebar.collapsed .sidebar-brand span {
    display: none;
}

.sidebar.collapsed .sidebar-menu li a span.nav-label {
    display: none;
}

.sidebar.collapsed .sidebar-menu li a {
    justify-content: center;
    padding: 14px 0;
    gap: 0;
}

.sidebar.collapsed .sidebar-footer {
    display: none;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 20px 0;
}

.sidebar.collapsed .sidebar-menu li a i {
    font-size: 1.1rem;
}

.sidebar.collapsed .sidebar-menu li a:hover::after {
    content: attr(data-tooltip);
    position: fixed;
    left: 76px;
    background: #1e293b;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 999;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Sidebar toggle button (desktop) */
.sidebar-collapse-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.sidebar-brand {
    padding: 24px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 24px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 4px solid transparent;
}

.sidebar-menu li a:hover,
.sidebar-menu li.active a {
    color: var(--text-light);
    background-color: rgba(255, 255, 255, 0.05);
    border-left-color: var(--accent);
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
}

.company-badge {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    color: var(--accent);
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main Content Wrapper */
.content-wrapper {
    margin-left: 260px;
    width: calc(100% - 260px);
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease, width 0.25s ease;
}

/* Adjust content when sidebar is collapsed */
body.sidebar-collapsed .content-wrapper {
    margin-left: 68px;
    width: calc(100% - 68px);
}

/* Top Navbar */
.top-navbar {
    height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Main Dashboard Body */
.main-content {
    padding: 32px;
    flex-grow: 1;
}

/* Cards & Grid */
.grid {
    display: grid;
    gap: 24px;
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

.card-footer-info {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Auth Screens */
.auth-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, var(--primary-light) 0%, var(--bg-main) 70%);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 480px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 2rem;
    color: var(--primary);
    font-weight: 800;
    margin-bottom: 5px;
}

.auth-header p {
    color: var(--text-muted);
}

/* Forms styling */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-main);
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

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

.form-row .form-group {
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    outline: none;
    font-size: 0.95rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.3);
}

.btn-secondary {
    background-color: var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* Tables styling */
.table-container {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-top: 24px;
}

.table-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.table-search {
    max-width: 300px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background-color: #f1f5f9;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.95rem;
    vertical-align: middle;
}

tr:hover td {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
}

.badge-pending {
    background-color: var(--warning-light);
    color: #b45309;
}

.badge-issued {
    background-color: var(--info-light);
    color: #1d4ed8;
}

.badge-paid {
    background-color: var(--success-light);
    color: #047857;
}

.badge-cancelled {
    background-color: var(--danger-light);
    color: #b91c1c;
}

/* Notifications */
.alert {
    padding: 16px 24px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success {
    background-color: var(--success-light);
    color: #065f46;
    border-left: 5px solid var(--success);
}

.alert-danger {
    background-color: var(--danger-light);
    color: #92400e;
    border-left: 5px solid var(--danger);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-container {
    background-color: var(--bg-card);
    width: 90%;
    max-width: 550px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    transform: scale(0.95);
    transition: var(--transition);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    padding: 16px 24px;
    background-color: #f8fafc;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Batch billing layout */
.batch-controls {
    background-color: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.batch-table td input.form-control {
    padding: 6px 12px;
    font-size: 0.9rem;
    max-width: 140px;
}

.batch-calculated-val {
    font-weight: 700;
    color: var(--primary);
}

/* Pagination links styling */
.pagination {
    display: flex;
    justify-content: flex-end;
    list-style: none;
    gap: 5px;
    padding: 20px 24px;
}

.pagination li a,
.pagination li span {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.pagination li.active span {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination li a:hover {
    background-color: var(--primary-light);
    color: var(--primary-hover);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
    -webkit-transform: translateX(26px);
    -ms-transform: translateX(26px);
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Billing Header Layout */
.billing-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.billing-filters-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex-grow: 1;
    max-width: 800px;
}

.billing-filters-form select,
.billing-filters-form input {
    flex: 1;
    min-width: 160px;
}

.billing-actions-wrapper {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Media Queries for Mobile Responsiveness */
.actions-flex-wrapper {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

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

.batch-summary-bar {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background-color: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 1024px) {
    /* Collapse Sidebar & Adjust Layout spacing */
    .sidebar {
        left: -260px;
        box-shadow: none;
    }
    .sidebar.active {
        left: 0;
        box-shadow: var(--shadow-lg);
    }
    .content-wrapper {
        margin-left: 0;
        width: 100% !important;
    }
    .top-navbar {
        padding: 0 16px;
    }
    .main-content {
        padding: 20px 16px;
    }
    #sidebar-toggle {
        display: block !important;
    }
    #sidebar-close {
        display: block !important;
    }

    /* Grid Adjustments */
    .grid {
        gap: 16px;
    }
    .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    /* Forms stacking */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .form-row .form-group {
        flex: unset;
        width: 100%;
    }

    /* Responsive Filters & Actions Header */
    .billing-header-container {
        flex-direction: column;
        align-items: stretch;
    }
    .billing-filters-form {
        max-width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    .billing-filters-form select,
    .billing-filters-form input {
        max-width: 100% !important;
        width: 100%;
    }
    .billing-filters-form button,
    .billing-filters-form a {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    .billing-actions-wrapper {
        flex-direction: column;
        width: 100%;
    }
    .billing-actions-wrapper button,
    .billing-actions-wrapper a {
        width: 100%;
        justify-content: center;
    }
    
    /* Batch billing summary bar stacks vertically */
    .batch-summary-bar {
        flex-direction: column !important;
        gap: 16px !important;
        align-items: stretch !important;
        text-align: center !important;
    }
    .batch-summary-bar button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Display mobile Select-All */
    .mobile-select-all-wrapper {
        display: block !important;
    }

    /* Responsive Table to Cards */
    .responsive-table {
        border: none;
        overflow-x: visible !important;
    }
    
    .responsive-table table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table th,
    .responsive-table td,
    .responsive-table tr {
        display: block !important;
        width: 100% !important;
    }
    
    .responsive-table thead {
        display: none !important;
    }
    
    .responsive-table tbody tr {
        background: var(--bg-card) !important;
        border: 1px solid var(--border) !important;
        border-radius: var(--radius) !important;
        padding: 16px !important;
        margin-bottom: 16px !important;
        box-shadow: var(--shadow-sm) !important;
        transition: var(--transition) !important;
        position: relative !important;
    }
    
    .responsive-table tbody tr:hover {
        transform: translateY(-2px) !important;
        box-shadow: var(--shadow) !important;
    }
    
    .responsive-table tbody td {
        border: none !important;
        border-bottom: 1px dashed var(--border) !important;
        padding: 12px 0 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        text-align: right !important;
        font-size: 0.95rem !important;
    }
    
    .responsive-table tbody td:last-child {
        border-bottom: none !important;
        padding-bottom: 0 !important;
        margin-top: 12px !important;
        display: flex !important;
        justify-content: flex-end !important;
    }
    
    .responsive-table tbody td::before {
        content: attr(data-label);
        font-weight: 600 !important;
        color: var(--text-muted) !important;
        text-align: left !important;
        display: inline-block !important;
        margin-right: 15px !important;
    }
    
    /* Checkbox TD */
    .responsive-table tbody td.td-checkbox {
        justify-content: flex-start !important;
        align-items: center !important;
        gap: 10px !important;
        border-bottom: 1px solid var(--border) !important;
        padding-top: 0 !important;
        padding-bottom: 12px !important;
        margin-bottom: 8px !important;
    }
    
    .responsive-table tbody td.td-checkbox::before {
        margin-right: auto !important;
    }
    
    /* Input columns inside Batch Billing Table on mobile */
    .responsive-table tbody td.td-input {
        flex-direction: column !important;
        align-items: stretch !important;
        text-align: left !important;
        gap: 8px !important;
    }
    
    .responsive-table tbody td.td-input::before {
        text-align: left !important;
        margin-bottom: 4px !important;
    }
    
    .responsive-table tbody td.td-input input.form-control {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Vertical stacking for long text fields to prevent screen overflow */
    .responsive-table tbody td.td-block,
    .responsive-table tbody td[data-label="Cliente"],
    .responsive-table tbody td[data-label="Nome"],
    .responsive-table tbody td[data-label="Contato"],
    .responsive-table tbody td[data-label="Endereço"],
    .responsive-table tbody td[data-label="Nosso Nº"],
    .responsive-table tbody td[data-label="Ações"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
        gap: 6px !important;
    }
    
    .responsive-table tbody td.td-block *,
    .responsive-table tbody td[data-label="Cliente"] *,
    .responsive-table tbody td[data-label="Nome"] *,
    .responsive-table tbody td[data-label="Contato"] *,
    .responsive-table tbody td[data-label="Endereço"] *,
    .responsive-table tbody td[data-label="Nosso Nº"] *,
    .responsive-table tbody td[data-label="Ações"] * {
        text-align: left !important;
    }
    
    .responsive-table tbody td.td-actions {
        align-items: flex-start !important;
        justify-content: flex-end !important;
    }
    
    .responsive-table tbody td.td-actions::before {
        margin-right: auto !important;
        margin-bottom: 6px !important;
    }
    
    .responsive-table tbody td.td-actions .actions-flex-wrapper {
        justify-content: flex-start !important;
        width: 100% !important;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 16px;
    }
    .auth-card {
        padding: 24px 16px;
    }
    .top-navbar {
        padding: 0 12px;
    }
    .page-title {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 180px;
    }
    .user-profile {
        gap: 8px;
    }
    .user-profile div:nth-child(2) {
        display: none; /* Hide user name string and only show avatar icon on extra-small mobile screens */
    }
}

/* Sidebar hidden state for both desktop and mobile */
body.sidebar-hidden .sidebar {
    transform: translateX(-100%) !important;
}
body.sidebar-hidden .content-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
}

/* Delivery Method Button Highlights */
.btn-highlighted-pdf {
    border: 2px solid var(--danger) !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.45) !important;
    font-weight: 700 !important;
}

.btn-highlighted-zap {
    border: 2px solid #2e7d32 !important;
    box-shadow: 0 0 10px rgba(46, 125, 50, 0.45) !important;
    font-weight: 700 !important;
}

.btn-highlighted-email {
    border: 2px solid #c62828 !important;
    box-shadow: 0 0 10px rgba(198, 40, 40, 0.45) !important;
    font-weight: 700 !important;
}

