@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

/* ============================================
   CSS Variables — CotiGo Static Theme
   Company colors do NOT override these.
   ============================================ */
:root {
    --brand-primary: #00f2ff;
    --brand-secondary: #7c3aed;
    --brand-glow: rgba(0, 242, 255, 0.4);
    --neon-text: #00f2ff;

    --bg-dark: #020617;
    --bg-sidebar: rgba(15, 23, 42, 0.8);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-heavy: rgba(255, 255, 255, 0.07);

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --sidebar-width: 280px;
    --header-height: 80px;
    --bottom-bar-height: 72px;
}

/* ============================================
   Reset & Base
   ============================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(34, 211, 238, 0.05) 0%, transparent 40%);
}

/* Utility */
.hidden {
    display: none !important;
}

/* Scrollbar — Hidden but functional */
* {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

*::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.auth-card::-webkit-scrollbar {
    width: 4px;
}

.auth-card::-webkit-scrollbar-track {
    background: transparent;
}

.auth-card::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.auth-card::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   Glassmorphism
   ============================================ */
.glass {
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
}

.glass-heavy {
    background: var(--glass-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ============================================
   Page Transitions
   ============================================ */
#views-container {
    opacity: 1;
    transition: opacity 0.2s ease-in-out;
}

#views-container.loading {
    opacity: 0.4;
    pointer-events: none;
}

/* Skeleton */
@keyframes skeleton-loading {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.03) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
    height: 1.5em;
    width: 100%;
    margin-bottom: 10px;
}

/* ============================================
   Toggle Switch
   ============================================ */
.toggle-switch-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.toggle-switch-container:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.toggle-switch {
    width: 44px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    position: relative;
    transition: 0.3s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="checkbox"]:checked~.toggle-switch-track .toggle-switch {
    background: var(--brand-primary);
    box-shadow: 0 0 10px var(--brand-glow);
}

input[type="checkbox"]:checked~.toggle-switch-track .toggle-switch::after {
    transform: translateX(20px);
}

/* ============================================
   Auth View
   ============================================ */
#auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    width: 100%;
    z-index: 2000;
    padding: 20px;
    overflow-y: auto;
}

.auth-card {
    width: 100%;
    max-width: 450px;
    padding: 30px 20px;
    border-radius: 32px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(0, 242, 255, 0.15);
    margin: auto;
    max-height: 95vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(0, 242, 255, 0.2);
}

@media (max-width: 768px) {
    .auth-card {
        max-width: 95%;
        padding: 30px 25px;
        border-radius: 24px;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 25px 20px;
        border-radius: 20px;
    }

    .logo-text {
        font-size: 2rem !important;
    }

    .auth-card img {
        width: 80px !important;
        height: 80px !important;
    }
}

/* ============================================
   Sidebar & Layout
   ============================================ */
aside {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 30px;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 30%, var(--brand-primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(0, 242, 255, 0.3);
}

.sidebar-logo span {
    color: var(--brand-primary);
    -webkit-text-fill-color: var(--brand-primary);
    filter: drop-shadow(0 0 8px var(--brand-glow));
}

nav ul {
    list-style: none;
}

nav li {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 16px;
    transition: all 0.3s ease;
    gap: 12px;
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    background: var(--glass-heavy);
    color: var(--text-main);
}

.nav-link.active {
    border-left: 4px solid var(--brand-primary);
}

main {
    padding: 40px;
    overflow-y: auto;
    height: 100vh;
}

/* ============================================
   Dashboard
   ============================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 40px;
}

.kpi-card {
    padding: 25px;
    border-radius: 24px;
}

.kpi-label {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 5px;
}

/* ============================================
   Tables
   ============================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.data-table th {
    text-align: left;
    padding: 15px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 20px 15px;
    border-bottom: 1px solid var(--border);
}

/* ============================================
   Badges
   ============================================ */
.badge {
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

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

input,
select,
textarea {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: white;
    outline: none;
    transition: all 0.3s ease;
}

input:focus {
    border-color: var(--brand-primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 20px var(--brand-glow);
}

/* Select personalizado para modal de unidad */
#prod-unidad {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 1rem;
    padding: 14px 18px;
    appearance: none;
    transition: all 0.3s ease;
}

#prod-unidad:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 20px var(--brand-glow);
}

#prod-unidad option {
    background: var(--bg-sidebar);
    color: var(--text-main);
}

/* Flecha personalizada */
#prod-unidad {
    background-image: url('data:image/svg+xml;utf8,<svg fill="%237c3aed" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 18px center;
    background-size: 24px 24px;
}

/* ============================================
   Buttons
   ============================================ */
.btn-primary {
    background: linear-gradient(135deg, #00f2ff 0%, #7c3aed 100%);
    border: none;
    padding: 14px 28px;
    border-radius: 14px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    box-shadow: 0 4px 15px rgba(0, 242, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 242, 255, 0.5);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--brand-primary);
    padding: 8px 16px;
    border-radius: 10px;
    color: var(--brand-primary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-secondary:hover {
    background: rgba(0, 242, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
    transform: translateY(-1px);
}

/* Icon Buttons for CRUD tables */
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: all 0.3s ease;
}

.icon-btn--edit {
    color: var(--brand-primary);
    margin-right: 10px;
}

.icon-btn--delete {
    color: var(--error);
}

/* ============================================
   Quote Builder
   ============================================ */
.quote-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
}

.line-items table {
    width: 100%;
}

.summary-card {
    position: sticky;
    top: 0;
}

.gradient-text {
    background: linear-gradient(to right, #fff, var(--brand-primary), var(--brand-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================
   Animations
   ============================================ */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.view-section {
    display: none;
    animation: slideIn 0.4s ease-out forwards;
}

.view-section.active {
    display: block;
}

@media (max-width: 600px) {
    #register-form>div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }

    #register-form h2,
    #login-form h2 {
        font-size: 1.5rem !important;
    }
}

/* ============================================
   Quotation Canvas (White WYSIWYG)
   ============================================ */
.quote-canvas {
    background: white !important;
    color: #334155 !important;
    padding: 60px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    max-width: 900px;
    margin: 0 auto;
    font-family: 'Outfit', sans-serif;
    border: 1px solid #e2e8f0;
}

.quote-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
}

.header-left {
    display: flex;
    gap: 20px;
    align-items: center;
}

.company-logo-container img {
    width: 65px;
    height: 65px;
    object-fit: contain;
}

.company-info h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.company-info p {
    font-size: 0.9rem;
    color: #64748b;
    margin: 5px 0 0 0;
}

.header-right {
    text-align: right;
    font-size: 0.95rem;
    color: #475569;
}

.header-right p {
    margin: 2px 0;
    font-weight: 600;
}

.header-right span {
    font-weight: 400;
}

.quote-number-title {
    font-size: 1.2rem;
    color: #1e293b;
    font-weight: 700;
    text-align: right;
    margin-top: 20px;
    letter-spacing: 0.5px;
}

.quote-meta {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 30px;
}

.meta-right {
    width: 300px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.9rem;
}

.meta-row label {
    font-weight: 700;
    color: #475569;
}

.inline-input {
    border: none !important;
    border-bottom: 1px dashed #cbd5e1 !important;
    background: transparent !important;
    color: #1e293b !important;
    padding: 4px !important;
    font-size: 0.9rem !important;
    width: 130px !important;
    text-align: right !important;
}

.inline-input:focus {
    outline: none !important;
    border-bottom: 1px solid var(--brand-primary) !important;
    box-shadow: none !important;
}

/* Client Info Block */
.client-info-block {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 40px;
}

.client-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.client-grid .field {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.5);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.client-grid .field.full {
    grid-column: span 2;
}

.client-grid label {
    font-weight: 700;
    font-size: 0.8rem;
    color: #64748b;
    white-space: nowrap;
    min-width: 80px;
}

.client-grid input {
    border: none !important;
    background: transparent !important;
    color: #1e293b !important;
    padding: 0 !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    width: 100% !important;
}

.client-grid input:focus {
    box-shadow: none !important;
}

/* Items Table */
.items-table-container {
    margin-bottom: 40px;
}

#quote-items-table {
    width: 100%;
    border-collapse: collapse;
}

#quote-items-table th {
    text-align: left;
    padding: 12px 15px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
    text-transform: uppercase;
}

#quote-items-table td {
    padding: 15px;
    border-bottom: 1px solid #f1f5f9;
}

#quote-items-table input {
    background: transparent !important;
    border: 1px solid transparent !important;
    padding: 5px !important;
    color: #334155 !important;
    font-size: 0.9rem !important;
}

#quote-items-table input:hover,
#quote-items-table input:focus {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

.btn-add-item {
    background: transparent;
    border: 1px dashed #cbd5e1;
    color: #64748b;
    padding: 10px;
    width: 100%;
    margin-top: 15px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
}

.btn-add-item:hover {
    background: #f1f5f9;
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* Bottom Section */
.bottom-section {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 40px;
}

.terms-column label {
    font-weight: 700;
    font-size: 0.9rem;
    color: #1e293b;
    display: block;
    margin-bottom: 15px;
}

.terms-column textarea {
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    font-size: 0.8rem !important;
    color: #64748b !important;
    line-height: 1.6 !important;
    resize: none !important;
    padding: 0 !important;
}

.totals-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.95rem;
    color: #475569;
}

.total-row span:first-child {
    font-weight: 700;
    color: #1e293b;
}

.total-row.grand-total {
    border-top: 2px solid #e2e8f0;
    padding-top: 15px;
    font-size: 1.2rem;
}

.total-row.grand-total span:last-child {
    font-weight: 800;
    color: #0f172a;
}

.quote-footer {
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    color: #94a3b8;
    font-size: 0.8rem;
}

.quote-actions {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.quote-canvas input::placeholder {
    color: #cbd5e1;
    font-weight: 400;
}

/* ============================================
   Button SVG Effects
   ============================================ */
button svg {
    transition: all 0.3s ease;
}

button:hover svg {
    transform: scale(1.15);
    filter: drop-shadow(0 0 8px currentColor);
}

button:active svg {
    transform: scale(0.95);
}

/* ============================================
   Toggle / Checkbox
   ============================================ */
.toggle-slider {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

label:hover .toggle-slider {
    box-shadow: 0 2px 8px rgba(0, 242, 255, 0.3);
}

#set-responsable-iva:checked+span {
    box-shadow: 0 0 12px var(--brand-glow);
}

/* ============================================
   SweetAlert2 Overrides
   ============================================ */
.swal2-popup {
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(20px);
    border: 1px solid var(--border) !important;
    border-radius: 24px !important;
    color: var(--text-main) !important;
    font-family: 'Outfit', sans-serif !important;
}

.swal2-title {
    color: var(--brand-primary) !important;
}

.swal2-html-container {
    color: var(--text-dim) !important;
}

.swal2-confirm {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary)) !important;
    border-radius: 12px !important;
    padding: 12px 30px !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 15px var(--brand-glow) !important;
}

.swal2-cancel {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 12px 30px !important;
    color: var(--text-main) !important;
}

.swal2-success-ring {
    border-color: var(--brand-primary) !important;
}

.swal2-success-line-tip,
.swal2-success-line-long {
    background-color: var(--brand-primary) !important;
}

/* ============================================
   Autocomplete Suggestions
   ============================================ */
.autocomplete-container {
    position: relative;
    width: 100%;
}

.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
}

.suggestion-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: rgba(0, 242, 255, 0.1);
    padding-left: 20px;
}

.suggestion-item .prod-name {
    font-weight: 700;
    color: var(--brand-primary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-item .prod-price {
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 600;
    white-space: nowrap;
}

.suggestions-dropdown::-webkit-scrollbar {
    width: 6px;
}

.suggestions-dropdown::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.suggestions-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}

/* ── Autocomplete inside the white quotation canvas ─────────────
   Overrides the global dark/cyan theme with clean neutral colors */
#generator-canvas .suggestions-dropdown {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-top: none !important;
    border-radius: 0 0 10px 10px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10) !important;
    backdrop-filter: none !important;
}

#generator-canvas .suggestion-item {
    border-bottom: 1px solid #f1f5f9 !important;
}

#generator-canvas .suggestion-item:hover {
    background: #f8fafc !important;
    padding-left: 20px;
}

#generator-canvas .suggestion-item .prod-name {
    color: #1e293b !important;
    font-size: 0.88rem;
    font-weight: 700;
}

#generator-canvas .suggestion-item .prod-price {
    color: #64748b !important;
    font-size: 0.82rem;
    font-weight: 600;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-notification {
    position: fixed;
    top: 30px;
    right: 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-radius: 14px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    transform: translateX(120%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    backdrop-filter: blur(20px);
    max-width: 400px;
}

.toast-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.toast-message {
    font-size: 0.95rem;
    color: var(--text-main);
}

.toast-success {
    border-color: var(--success);
}

.toast-success .toast-icon {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.toast-error {
    border-color: var(--error);
}

.toast-error .toast-icon {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.toast-warning {
    border-color: var(--warning);
}

.toast-warning .toast-icon {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.toast-info {
    border-color: var(--brand-primary);
}

.toast-info .toast-icon {
    background: rgba(0, 242, 255, 0.2);
    color: var(--brand-primary);
}

/* ============================================
   Color Preview (Settings page only)
   ============================================ */
.color-preview-bar {
    height: 8px;
    border-radius: 4px;
    margin-top: 15px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    transition: background 0.3s ease;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-block;
    border: 2px solid var(--border);
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE & TABLET
   ============================================ */

/* ========== TABLET (768px - 1024px) ========== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 250px;
        --header-height: 70px;
    }

    /* Reduce font sizes slightly */
    body {
        font-size: 15px;
    }

    /* Sidebar adjustments */
    aside {
        padding: 25px 20px;
    }

    .sidebar-logo {
        font-size: 1.3rem;
        margin-bottom: 40px;
    }

    .logo-text {
        font-size: 1.6rem;
    }

    .nav-link {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    /* Main content */
    main {
        padding: 30px;
    }

    /* Dashboard KPI grid */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .kpi-card {
        padding: 20px;
    }

    .kpi-value {
        font-size: 1.8rem;
    }

    /* Quote generator canvas */
    #generator-canvas {
        padding: 40px !important;
    }

    /* Tables */
    .data-table th,
    .data-table td {
        padding: 12px 10px;
        font-size: 0.9rem;
    }
}

/* ============================================
   SEARCH BAR
   ============================================ */
.search-bar {
    position: relative;
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    background: var(--glass-heavy);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-main);
    font-size: 0.92rem;
    font-family: inherit;
    transition: all 0.3s ease;
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-dim);
    font-weight: 400;
}

.search-bar input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0, 242, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.search-bar .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
    transition: color 0.3s ease;
}

.search-bar input:focus~.search-icon,
.search-bar:focus-within .search-icon {
    color: var(--brand-primary);
}

.search-bar .search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    display: none;
    transition: color 0.2s;
}

.search-bar .search-clear:hover {
    color: var(--error);
}

.search-bar.has-value .search-clear {
    display: block;
}

.search-count {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 6px;
    padding-left: 4px;
}

/* ========== MOBILE (max 768px) ========== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    /* Body adjustments */
    body {
        overflow-y: auto;
    }

    /* ===== MOBILE NAVIGATION ===== */
    /* Hide desktop sidebar completely */
    #app-container {
        grid-template-columns: 1fr !important;
        position: relative;
    }

    aside {
        display: none !important;
    }

    /* Main content adjustments — leave space top & bottom */
    main {
        padding: 20px 16px calc(var(--bottom-bar-height) + 20px) 16px;
        height: auto;
        min-height: 100vh;
        overflow-y: visible;
    }

    /* ===== DASHBOARD ===== */
    .kpi-grid {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
        margin-bottom: 24px;
    }

    .kpi-grid::-webkit-scrollbar {
        display: none;
    }

    .kpi-card {
        min-width: 160px;
        flex-shrink: 0;
        scroll-snap-align: start;
        padding: 18px;
    }

    .kpi-value {
        font-size: 1.8rem;
    }

    .kpi-label {
        font-size: 0.78rem;
    }

    /* ===== RESPONSIVE CARD TABLES ===== */
    /* On mobile, convert data-tables into stacked card list */
    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .data-table th,
    .data-table td {
        display: block;
    }

    .data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .data-table tbody tr {
        background: var(--glass-heavy);
        border: 1px solid var(--border);
        border-radius: 14px;
        margin-bottom: 12px;
        padding: 16px;
        position: relative;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 16px;
        overflow: hidden;
    }

    .data-table td {
        padding: 4px 0;
        font-size: 0.88rem;
        white-space: normal;
        min-width: 0;
        max-width: 100%;
        text-align: left;
        border: none;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .data-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.68rem;
        font-weight: 700;
        color: var(--text-dim);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 2px;
    }

    /* Action column spans full width at bottom */
    .data-table td.table-actions,
    .data-table td:last-child {
        grid-column: 1 / -1;
        display: flex;
        gap: 8px;
        padding-top: 10px;
        margin-top: 4px;
        border-top: 1px solid var(--border);
        justify-content: flex-end;
    }

    .data-table td.table-actions::before,
    .data-table td:last-child::before {
        display: none;
    }

    /* Action buttons inside cards */
    .data-table .table-actions button,
    .data-table td:last-child button {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid var(--border) !important;
        transition: all 0.2s ease;
    }

    .data-table .table-actions button:active,
    .data-table td:last-child button:active {
        transform: scale(0.92);
        background: rgba(255, 255, 255, 0.1) !important;
    }

    /* ===== VIEW HEADERS ===== */
    /* Keep header title & button in one row, compact */
    #views-container>header[style*="justify-content: space-between"],
    #views-container header[style*="justify-content: space-between"] {
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
    }

    #views-container header h2 {
        font-size: 1.2rem !important;
        margin: 0;
    }

    #views-container header .btn-secondary {
        padding: 8px 14px !important;
        font-size: 0.8rem !important;
    }

    /* ===== FORMS ===== */
    input,
    select,
    textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 12px 16px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    /* ===== BUTTONS ===== */
    .btn-primary {
        padding: 14px 24px;
        font-size: 1rem;
    }

    .btn-secondary {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    /* ===== QUOTE GENERATOR ===== */
    #generator-canvas {
        max-width: 100% !important;
        padding: 20px 16px !important;
        margin: 0 !important;
        border-radius: 14px !important;
        min-height: auto !important;
    }

    /* Header section - stack vertically */
    #generator-canvas>div:first-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 20px !important;
    }

    #generator-canvas>div:first-child>div:first-child {
        flex-direction: row !important;
        gap: 14px !important;
    }

    #generator-canvas>div:first-child>div:last-child {
        text-align: left !important;
        width: 100% !important;
    }

    #canvas-logo {
        width: 60px !important;
        height: 60px !important;
    }

    #canvas-company-name {
        font-size: 1.3rem !important;
    }

    #canvas-company-slogan {
        font-size: 0.82rem !important;
    }

    /* Quote number section */
    #generator-canvas h2 {
        font-size: 1.6rem !important;
    }

    /* Dates - stack vertically */
    #generator-canvas>div:first-child>div:last-child>div {
        flex-direction: column !important;
        gap: 8px !important;
    }

    #generator-canvas>div:first-child>div:last-child>div>div {
        justify-content: space-between !important;
    }

    #quote-date-exp,
    #quote-date-valid {
        width: 100% !important;
        text-align: left !important;
    }

    /* Client info grid - single column */
    #generator-canvas>div:nth-child(2)>div:last-child {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        padding: 16px !important;
    }

    /* Items table - horizontal scroll with visual hint */
    #generator-canvas>div:nth-child(3) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }

    #generator-canvas table {
        min-width: 560px;
    }

    #generator-canvas th,
    #generator-canvas td {
        padding: 10px 6px !important;
        font-size: 0.78rem !important;
    }

    #generator-canvas th:nth-child(1) {
        width: 50px;
    }

    #generator-canvas th:nth-child(3) {
        width: 85px;
    }

    #generator-canvas th:nth-child(4) {
        width: 65px;
    }

    #generator-canvas th:nth-child(5) {
        width: 85px;
    }

    #generator-canvas th:nth-child(6) {
        width: 32px;
    }

    #generator-canvas input[type="number"],
    #generator-canvas input[type="text"] {
        font-size: 0.85rem !important;
    }

    /* Add item button - full width mobile */
    #generator-canvas .no-print button {
        width: 100%;
        justify-content: center;
    }

    /* ===== TERMS & TOTALS SECTION ===== */
    /* Stack terms and totals vertically */
    #generator-canvas>div:last-child {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }

    /* Terms block */
    #generator-canvas>div:last-child>div:first-child {
        order: 2;
        /* Move terms below totals on mobile */
    }

    /* Totals block */
    #generator-canvas>div:last-child>div:last-child {
        order: 1;
    }

    #quote-terms-list {
        font-size: 0.82rem !important;
    }

    #quote-terms-list li {
        margin-bottom: 6px !important;
    }

    /* Action buttons — inline bar at bottom of module */
    .action-bar-float {
        display: flex !important;
        flex-direction: row !important;
        margin: 18px 0 calc(var(--bottom-bar-height) + 16px) 0 !important;
        justify-content: center !important;
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
    }

    .action-bar-float .btn-primary,
    .action-bar-float .btn-secondary,
    .action-bar-float button {
        flex: 1 !important;
        justify-content: center !important;
        padding: 12px 10px !important;
        font-size: 0.82rem !important;
        border-radius: 12px !important;
        white-space: nowrap !important;
        gap: 6px !important;
    }

    /* ===== MODALS ===== */
    .swal2-popup {
        width: 90% !important;
        max-width: 400px !important;
        padding: 20px !important;
    }

    /* ===== TOAST NOTIFICATIONS ===== */
    .toast-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: calc(100% - 20px);
        font-size: 0.9rem;
    }

    /* ===== AUTH CARD ===== */
    #auth-container {
        padding: 15px;
    }

    .auth-card {
        padding: 25px 20px;
        border-radius: 20px;
    }

    /* ===== QUOTE CANVAS (White) ===== */
    .quote-canvas {
        padding: 30px 20px !important;
    }

    .quote-header {
        flex-direction: column;
        gap: 20px;
    }

    .header-left {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-right {
        text-align: left !important;
        width: 100%;
    }

    .quote-number-title {
        text-align: left !important;
    }

    .client-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .client-grid .field.full {
        grid-column: span 1;
    }

    .bottom-section {
        grid-template-columns: 1fr !important;
        gap: 30px;
    }

    /* ===== SETTINGS PAGE ===== */
    #settings-form {
        padding: 20px;
    }

    /* Settings grid - stack cards vertically */
    #views-container>div[style*="grid-template-columns: 1fr 1fr"],
    #views-container div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* Settings theme buttons grid */
    #views-container div[style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Settings color pickers grid */
    #views-container div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    /* Glass cards in settings */
    .glass {
        padding: 20px !important;
    }

    /* ===== AUTOCOMPLETE / SUGGESTIONS ===== */
    .suggestions-dropdown {
        max-height: 240px;
        z-index: 500 !important;
    }

    .suggestion-item {
        padding: 12px 14px;
        font-size: 0.88rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Suggestions inside the quote generator (white bg) */
    #generator-canvas .suggestions-dropdown {
        position: absolute !important;
        left: 0 !important;
        right: 0 !important;
        max-height: 220px;
        z-index: 200 !important;
    }

    #generator-canvas .suggestion-item {
        padding: 12px 14px;
        font-size: 0.88rem;
    }

    #generator-canvas .autocomplete-container {
        position: relative;
    }
}

/* ========== VERY SMALL MOBILE (max 480px) ========== */
@media (max-width: 480px) {

    /* Typography adjustments */
    h1 {
        font-size: 1.8rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.2rem !important;
    }

    /* Main padding */
    main {
        padding: 12px 12px calc(var(--bottom-bar-height) + 16px) 12px;
    }

    /* Dashboard */
    .kpi-card {
        min-width: 140px !important;
        padding: 14px !important;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .kpi-label {
        font-size: 0.75rem;
    }

    /* Cards: single column on tiny screens */
    .data-table tbody tr {
        grid-template-columns: 1fr !important;
        gap: 6px !important;
        padding: 14px !important;
    }

    /* Buttons */
    .btn-primary,
    .btn-secondary {
        font-size: 0.9rem;
        padding: 12px 20px;
    }

    /* Generator canvas */
    #generator-canvas {
        padding: 20px 15px !important;
    }

    #canvas-company-name {
        font-size: 1.3rem !important;
    }

    #canvas-logo {
        width: 60px !important;
        height: 60px !important;
    }

    /* Icon buttons smaller touch targets */
    .icon-btn {
        padding: 6px;
    }

    /* Auth logo */
    .auth-card img {
        width: 80px !important;
        height: 80px !important;
    }

    .logo-text {
        font-size: 2rem !important;
    }
}

/* ============================================
   BOTTOM NAVIGATION BAR (Mobile Only)
   ============================================ */

/* Hidden on desktop by default */
.bottom-nav,
.fab-button,
.more-menu {
    display: none;
}

@media (max-width: 768px) {

    /* ===== BOTTOM NAV BAR ===== */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--bottom-bar-height);
        display: flex;
        align-items: center;
        justify-content: space-around;
        z-index: 1000;
        background: rgba(2, 6, 23, 0.88);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        padding: 0 8px;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .bottom-nav__item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        text-decoration: none;
        color: var(--text-dim);
        font-size: 0.65rem;
        font-weight: 500;
        letter-spacing: 0.3px;
        padding: 8px 0;
        min-width: 56px;
        border: none;
        background: none;
        cursor: pointer;
        position: relative;
        transition: color 0.25s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .bottom-nav__item svg {
        transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .bottom-nav__item.active {
        color: var(--brand-primary);
    }

    .bottom-nav__item.active svg {
        transform: scale(1.1);
        filter: drop-shadow(0 0 6px rgba(0, 242, 255, 0.4));
    }

    .bottom-nav__item.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 24px;
        height: 3px;
        background: var(--brand-primary);
        border-radius: 0 0 4px 4px;
        box-shadow: 0 2px 8px rgba(0, 242, 255, 0.5);
    }

    .bottom-nav__item:active svg {
        transform: scale(0.85);
    }

    .bottom-nav__spacer {
        width: 64px;
        flex-shrink: 0;
    }

    /* ===== FAB BUTTON ===== */
    .fab-button {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: calc(var(--bottom-bar-height) - 24px);
        left: 50%;
        transform: translateX(-50%);
        width: 58px;
        height: 58px;
        border-radius: 50%;
        border: none;
        background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #6366f1 100%);
        color: white;
        cursor: pointer;
        z-index: 1002;
        box-shadow:
            0 4px 20px rgba(99, 102, 241, 0.5),
            0 0 40px rgba(99, 102, 241, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
        transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        -webkit-tap-highlight-color: transparent;
    }

    .fab-button::before {
        content: '';
        position: absolute;
        inset: -3px;
        border-radius: 50%;
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(139, 92, 246, 0.3));
        z-index: -1;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .fab-button:active {
        transform: translateX(-50%) scale(0.9);
    }

    .fab-button:active::before {
        opacity: 1;
    }

    /* Pulse animation on FAB */
    @keyframes fab-pulse {

        0%,
        100% {
            box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5), 0 0 40px rgba(99, 102, 241, 0.15);
        }

        50% {
            box-shadow: 0 4px 30px rgba(99, 102, 241, 0.7), 0 0 60px rgba(99, 102, 241, 0.25);
        }
    }

    .fab-button {
        animation: fab-pulse 3s ease-in-out infinite;
    }

    /* ===== MORE MENU POPUP ===== */
    .more-menu {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 1003;
    }

    .more-menu.open {
        display: block;
    }

    .more-menu__backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(4px);
        animation: fadeIn 0.2s ease;
    }

    .more-menu__panel {
        position: absolute;
        bottom: calc(var(--bottom-bar-height) + 12px);
        right: 16px;
        min-width: 200px;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(24px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 16px;
        padding: 8px;
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
        animation: slideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
        transform-origin: bottom right;
    }

    .more-menu__item {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        padding: 14px 16px;
        border: none;
        background: none;
        color: var(--text-main);
        font-size: 0.9rem;
        font-weight: 500;
        font-family: inherit;
        border-radius: 10px;
        cursor: pointer;
        text-decoration: none;
        transition: background 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .more-menu__item:active {
        background: rgba(255, 255, 255, 0.08);
    }

    .more-menu__item svg {
        color: var(--text-dim);
        flex-shrink: 0;
    }

    .more-menu__item--danger {
        color: #ef4444;
    }

    .more-menu__item--danger svg {
        color: #ef4444;
    }

    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translateY(10px) scale(0.95);
        }

        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }
}

/* ========== LANDSCAPE MODE OPTIMIZATIONS ========== */
@media (max-width: 768px) and (orientation: landscape) {
    main {
        padding: 15px 16px calc(var(--bottom-bar-height) + 10px) 16px;
    }

    .bottom-nav {
        height: 56px;
    }

    .fab-button {
        width: 48px;
        height: 48px;
        bottom: 32px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========== TOUCH OPTIMIZATIONS ========== */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .nav-link {
        padding: 16px 20px;
        min-height: 48px;
    }

    button,
    .btn-primary,
    .btn-secondary {
        min-height: 44px;
        min-width: 44px;
    }

    .icon-btn {
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .nav-link:hover,
    .btn-secondary:hover,
    button:hover svg {
        transform: none;
        box-shadow: none;
    }

    /* Active states instead */
    .nav-link:active,
    .btn-secondary:active {
        transform: scale(0.97);
    }
}

/* ========== PREVENT HORIZONTAL SCROLL ========== */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    * {
        max-width: 100%;
    }

    #app-container,
    main,
    .glass,
    .glass-heavy {
        overflow-x: hidden;
    }
}

/* ========== HIGH DPI SCREENS ========== */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    /* Sharper borders and shadows */
    .glass,
    .glass-heavy {
        border-width: 0.5px;
    }
}

/* ========== PRINT STYLES ========== */
@media print {

    aside,
    .bottom-nav,
    .fab-button,
    .more-menu,
    .no-print {
        display: none !important;
    }

    #app-container {
        grid-template-columns: 1fr !important;
    }

    main {
        padding: 0 !important;
    }

    #generator-canvas {
        box-shadow: none !important;
        border: none !important;
        padding: 15mm !important;
    }
}

/* ============================================
   Offline Banner
   ============================================ */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--error), #dc2626);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    animation: slideDown 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

.offline-banner svg {
    flex-shrink: 0;
    opacity: 0.9;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}