/* style.css - Stable V3 (HEX Colors + Overflow Fix) */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=PT+Sans:wght@400;700&display=swap');

:root {
    /* COLORS (Direct HEX for stability) */
    --background: #f1f5f9;
    /* Slate-100 */
    --foreground: #0f172a;
    /* Slate-900 */

    --card: #ffffff;

    /* White */
    :root {
        /* COLORS */
        --background: #f1f5f9;
        --foreground: #0f172a;

        --card: #ffffff;
        --primary: #fcd34d;
        /* FIX: Back to correct Yellow (Amber-300) */

        --accent: #06b6d4;
        --accent-text: #ffffff;

        --muted: #f8fafc;
        --muted-text: #64748b;

        --border: #e2e8f0;
        --radius: 0.5rem;
    }

    /* ... (Existing Reset & Body styles remain same) ... */

    /* Header Strip */
    body::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 120px;
        background: var(--primary);
        z-index: 0;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    }

    /* ... (Fonts & Container logic same as before) ... */

    /* SUMMARY GRID - COMPACT & RESPONSIVE */
    .summary-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.5rem;
        /* Tight gap */
        margin-bottom: 2rem;
        width: 100%;
    }

    .summary-card:first-child {
        grid-column: span 2;
    }

    .summary-card {
        background: #f8fafc;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 0.75rem;
        /* Reduced padding */
        display: flex;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
        min-width: 0;
    }

    .summary-icon {
        width: 36px;
        height: 36px;
        /* Smaller icon */
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        font-size: 1rem;
    }

    .icon-blue {
        background: #eff6ff;
        color: #3b82f6;
    }

    .icon-green {
        background: #f0fdf4;
        color: #22c55e;
    }

    .icon-red {
        background: #fef2f2;
        color: #ef4444;
    }

    .summary-content {
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }

    .summary-label {
        font-size: 0.65rem;
        color: var(--muted-text);
        text-transform: uppercase;
        font-weight: 700;
        margin-bottom: 2px;
    }

    /* Responsive Font Size: Fits container "si o si" */
    .summary-value {
        font-size: clamp(0.9rem, 4vw, 1.15rem);
        /* Dynamic sizing */
        font-weight: 700;
        color: var(--foreground);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    --accent: #06b6d4;
    /* Cyan-500 */
    --accent-text: #ffffff;
    /* White text on button */

    --muted: #f8fafc;
    /* Slate-50 (Input bg) */
    --muted-text: #64748b;
    /* Slate-500 */

    --border: #e2e8f0;
    /* Slate-200 */
    --radius: 0.5rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'PT Sans', sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 0;
    overflow-x: hidden;
    position: relative;
}

/* Header Strip */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: var(--primary);
    z-index: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

h1,
h2,
h3,
.logo-text,
.summary-value,
.btn-primary {
    font-family: 'Poppins', sans-serif;
}

.container {
    width: 100%;
    max-width: 450px;
    /* Slightly tighter to prevent stretching */
    position: relative;
    z-index: 10;
    padding: 1rem;
    margin-top: 3rem;
}

/* View Toggle Logic */
.view-section {
    display: none !important;
    animation: fadeIn 0.3s ease-out;
}

.view-section.active {
    display: block !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* MAIN CARD */
.glass-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    /* CRITICAL FIX: Overflow hidden to cut off any child sticking out */
    overflow: hidden;
    position: relative;
}

/* Login */
.logo-area {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-text {
    font-size: 2rem;
    font-weight: 700;
    color: var(--foreground);
    letter-spacing: -0.5px;
}

.input-field {
    width: 100%;
    background: var(--muted);
    border: 1px solid var(--border);
    color: var(--foreground);
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 1.1rem;
    text-align: center;
    font-family: 'PT Sans', sans-serif;
}

.input-field:focus {
    border-color: var(--accent);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

/* Button */
.btn-primary {
    width: 100%;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 1rem;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(6, 182, 212, 0.2);
    transition: transform 0.1s;
}

.btn-primary:active {
    transform: scale(0.98);
}

/* HEADER ROW IN DASHBOARD */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* SUMMARY GRID - FIXED LAYOUT */
.summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    /* CRITICAL FIX: Forces containment */
    gap: 0.75rem;
    margin-bottom: 2rem;
    width: 100%;
}

.summary-card:first-child {
    grid-column: span 2;
}

.summary-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    min-width: 0;
    /* Flexbox shrink fix */
}

.summary-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.icon-blue {
    background: #eff6ff;
    color: #3b82f6;
}

.icon-green {
    background: #f0fdf4;
    color: #22c55e;
}

.icon-red {
    background: #fef2f2;
    color: #ef4444;
}

.summary-content {
    min-width: 0;
    /* Flexbox text wrap fix */
    flex: 1;
    overflow: hidden;
    /* Ensure text truncates */
}

.summary-label {
    font-size: 0.7rem;
    color: var(--muted-text);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 2px;
}

.summary-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Truncate if too long */
}

/* Timeline */
.timeline-title {
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
    color: var(--foreground);
    font-weight: 700;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
    padding-bottom: 2px;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.timeline-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: background 0.2s;
    width: 100%;
}

.timeline-item:hover {
    background: #f0f9ff;
    border-color: var(--accent);
}

.item-desc {
    font-weight: 600;
    font-size: 0.95rem;
    color: #334155;
}

.item-status {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #64748b;
    margin-top: 4px;
    display: inline-block;
}

.item-date {
    font-size: 0.75rem;
    color: var(--muted-text);
}

.text-success {
    color: #15803d;
}

.text-danger {
    color: #b91c1c;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 450px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-top: 4px solid var(--primary);
    padding: 1.5rem;
    transform: translateY(20px);
    transition: transform 0.2s ease-out;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-overlay.open .modal-content {
    transform: translateY(0);
}

/* Logic Utils */
.invoice-detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.detail-divider {
    height: 1px;
    background: var(--border);
    margin: 0.8rem 0;
}

.loader {
    width: 18px;
    height: 18px;
    border: 2px solid #fff;
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: rot 1s linear infinite;
    margin: auto;
    display: none;
}

@keyframes rot {
    100% {
        transform: rotate(360deg);
    }
}

.btn-primary.loading .btn-text {
    display: none;
}

.btn-primary.loading .loader {
    display: block;
}