/* ================================================
   Cotizaciones — Sistema Noor
   Extends the existing glassmorphism design system
   ================================================ */

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99,102,241,0.3);
    --accent: #ec4899;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --bg-dark: #0f172a;
    --bg-darker: #080e1e;
    --card-bg: rgba(30, 41, 59, 0.65);
    --card-bg-solid: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --input-bg: rgba(15, 23, 42, 0.6);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 25px 50px -12px rgba(0,0,0,0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Animated Background ===== */
.background-container {
    position: fixed;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    filter: blur(100px);
    border-radius: 50%;
    animation: float 20s infinite alternate cubic-bezier(0.5, 0, 0.5, 1);
    opacity: 0.35;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: #4f46e5;
    top: -150px;
    left: -100px;
    animation-duration: 28s;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: #ec4899;
    bottom: -100px;
    right: -100px;
    animation-duration: 22s;
    animation-delay: -5s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: #06b6d4;
    top: 50%;
    left: 50%;
    animation-duration: 25s;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(80px, -60px) scale(1.15); }
    66% { transform: translate(-40px, 80px) scale(0.95); }
    100% { transform: translate(60px, 40px) scale(1.05); }
}

/* ===== Top Navigation ===== */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 30px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px;
    flex-shrink: 0;
}

.nav-left h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.nav-accent {
    color: var(--accent);
    font-weight: 400;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-user {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 6px 14px;
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: all 0.25s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-main);
}

/* ===== Main Content ===== */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px;
}

/* ===== Views ===== */
.view {
    display: none;
    animation: viewFadeIn 0.35s ease forwards;
}

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

@keyframes viewFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Section Header ===== */
.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.section-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-top: 6px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ===== Stats Row ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all 0.3s;
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 800;
}

.stat-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ===== Glass Card ===== */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 24px;
    transition: border-color 0.3s;
}

.glass-card:hover {
    border-color: var(--border-hover);
}

/* ===== Table ===== */
.table-container {
    overflow-x: auto;
}

.table-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.table-empty p {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 16px;
    color: var(--text-dim);
}

.table-empty span {
    font-size: 0.85rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    text-align: left;
    padding: 14px 16px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody td {
    padding: 14px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.3px;
}

.badge-borrador {
    background: rgba(250,204,21,0.12);
    color: #fbbf24;
    border: 1px solid rgba(250,204,21,0.2);
}

.badge-enviada {
    background: rgba(59,130,246,0.12);
    color: #60a5fa;
    border: 1px solid rgba(59,130,246,0.2);
}

.badge-aceptada {
    background: rgba(16,185,129,0.12);
    color: #34d399;
    border: 1px solid rgba(16,185,129,0.2);
}

.badge-rechazada {
    background: rgba(239,68,68,0.12);
    color: #f87171;
    border: 1px solid rgba(239,68,68,0.2);
}

/* Action Buttons in Table */
.action-btns {
    display: flex;
    gap: 6px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
}

.action-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-main);
    border-color: var(--border-hover);
}

.action-btn.delete-action:hover {
    background: rgba(239,68,68,0.12);
    color: #f87171;
    border-color: rgba(239,68,68,0.3);
}

/* ===== Form Styles ===== */
.quote-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-section {
    padding: 24px;
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

.input-group {
    text-align: left;
}

.input-group.full-width {
    grid-column: 1 / -1;
}

.input-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.3s ease;
    outline: none;
}

.input-group textarea {
    resize: vertical;
    min-height: 70px;
}

.input-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-group input::placeholder,
.input-group textarea::placeholder {
    color: var(--text-dim);
}

/* ===== Items Table ===== */
.items-section {
    padding: 24px;
}

.items-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.items-table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

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

.items-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.items-table tbody td {
    padding: 8px 6px;
    vertical-align: top;
}

.items-table input,
.items-table textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}

.items-table input:focus,
.items-table textarea:focus {
    border-color: var(--primary);
}

.items-table textarea {
    resize: vertical;
    min-height: 40px;
}

.items-table .col-concept { width: 22%; }
.items-table .col-desc { width: 30%; }
.items-table .col-qty { width: 10%; }
.items-table .col-price { width: 16%; }
.items-table .col-total { width: 14%; }
.items-table .col-actions { width: 8%; }

.item-total-display {
    padding: 10px 12px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
}

.remove-item-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    margin-top: 4px;
}

.remove-item-btn:hover {
    background: rgba(239,68,68,0.12);
    color: #f87171;
    border-color: rgba(239,68,68,0.3);
}

/* ===== Totals ===== */
.totals-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.total-row {
    display: flex;
    justify-content: space-between;
    width: 280px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.total-row span:last-child {
    font-weight: 600;
    color: var(--text-main);
}

.total-final {
    padding-top: 10px;
    margin-top: 4px;
    border-top: 2px solid var(--primary);
    font-size: 1.15rem;
}

.total-final span:last-child {
    font-weight: 800;
    color: var(--primary);
    font-size: 1.25rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    white-space: nowrap;
}

.primary-btn {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.outline-btn {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.outline-btn:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--border-hover);
}

.ghost-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 8px 4px;
}

.ghost-btn:hover {
    color: var(--text-main);
}

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

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

.small-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.accent-btn {
    background: rgba(99,102,241,0.12);
    color: #818cf8;
    border: 1px solid rgba(99,102,241,0.2);
}

.accent-btn:hover {
    background: rgba(99,102,241,0.2);
}

.icon-btn svg {
    flex-shrink: 0;
}

/* ===== Messages ===== */
.message {
    font-size: 0.85rem;
    margin-top: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    display: none;
    text-align: center;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.success-message {
    background: rgba(34, 197, 94, 0.1);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ===== PDF Preview ===== */
.pdf-page {
    background: #ffffff;
    color: #1e293b;
    max-width: 800px;
    margin: 0 auto;
    padding: 50px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    line-height: 1.6;
}

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

.pdf-company {
    display: flex;
    align-items: center;
    gap: 14px;
}

.pdf-logo {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #6366f1, #ec4899);
    border-radius: 12px;
    flex-shrink: 0;
}

.pdf-company h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 2px;
}

.pdf-company p {
    font-size: 0.85rem;
    color: #64748b;
}

.pdf-quote-info {
    text-align: right;
}

.pdf-quote-info h3 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #6366f1;
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.pdf-quote-info p {
    font-size: 0.85rem;
    color: #64748b;
}

.pdf-divider {
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #ec4899);
    border-radius: 2px;
    margin: 20px 0 25px;
}

.pdf-client-section,
.pdf-project-section {
    margin-bottom: 22px;
}

.pdf-client-section h4,
.pdf-project-section h4,
.pdf-notes h4 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #6366f1;
    margin-bottom: 8px;
    font-weight: 700;
}

.pdf-client-section p,
.pdf-project-section p {
    font-size: 0.9rem;
    color: #334155;
    margin-bottom: 2px;
}

.pdf-project-name {
    font-weight: 700;
    font-size: 1.05rem !important;
    color: #0f172a !important;
}

.pdf-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.pdf-items-table thead th {
    background: #f1f5f9;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
}

.pdf-items-table thead th:first-child {
    border-radius: 8px 0 0 0;
}

.pdf-items-table thead th:last-child {
    border-radius: 0 8px 0 0;
    text-align: right;
}

.pdf-items-table tbody td {
    padding: 12px 14px;
    font-size: 0.88rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.pdf-items-table tbody td:last-child {
    text-align: right;
    font-weight: 600;
}

.pdf-totals {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    margin-top: 10px;
}

.pdf-total-row {
    display: flex;
    justify-content: space-between;
    width: 260px;
    font-size: 0.9rem;
    color: #64748b;
    padding: 4px 0;
}

.pdf-total-row span:last-child {
    font-weight: 600;
    color: #1e293b;
}

.pdf-total-final {
    padding-top: 10px;
    margin-top: 4px;
    border-top: 2px solid #6366f1;
    font-size: 1.1rem;
}

.pdf-total-final span:last-child {
    font-weight: 800;
    color: #6366f1;
    font-size: 1.2rem;
}

.pdf-notes {
    margin-top: 30px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 10px;
    border-left: 3px solid #6366f1;
}

.pdf-notes p {
    font-size: 0.85rem;
    color: #475569;
    white-space: pre-wrap;
}

.pdf-footer {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.pdf-footer p {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 2px;
}

/* ===== Print Styles ===== */
@media print {
    body {
        background: white !important;
        color: #1e293b !important;
    }

    .background-container,
    .top-nav,
    .no-print,
    .section-header {
        display: none !important;
    }

    .main-content {
        max-width: none;
        padding: 0;
        margin: 0;
    }

    .view {
        display: none !important;
    }

    #preview-view {
        display: block !important;
    }

    .pdf-page {
        box-shadow: none;
        border-radius: 0;
        padding: 30px 40px;
        max-width: none;
    }

    .pdf-divider {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .pdf-items-table thead th {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        background: #f1f5f9 !important;
    }

    .pdf-total-final {
        border-top-color: #6366f1 !important;
    }

    .pdf-notes {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .pdf-logo {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 16px;
    }
    .section-header {
        flex-direction: column;
    }
    .stats-row {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .form-row.three-col {
        grid-template-columns: 1fr;
    }
    .top-nav {
        padding: 12px 16px;
    }
    .nav-user {
        display: none;
    }
    .total-row, .pdf-total-row {
        width: 100%;
    }
    .totals-section, .pdf-totals {
        align-items: stretch;
    }
    .pdf-header {
        flex-direction: column;
        gap: 16px;
    }
    .pdf-quote-info {
        text-align: left;
    }
    .pdf-page {
        padding: 24px;
    }
}
