@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --accent: #3b82f6;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --bg-main: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-highlight: rgba(99, 102, 241, 0.4);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-inverse: #0f172a;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-glow: 0 10px 30px -10px rgba(99, 102, 241, 0.3);
    --glass-backdrop: blur(16px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 10% 20%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(59, 130, 246, 0.15) 0px, transparent 50%);
}

/* Header & Nav */
.navbar {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: var(--glass-backdrop);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 0;
}

.container {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 24px;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.logo-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.4rem;
    color: #fff;
    text-decoration: none;
    letter-spacing: -0.5px;
}

.logo-badge {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    white-space: normal;
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    word-break: break-word;
    line-height: 1.3;
}

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

.credit-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid #10b981;
    color: #61f8bc;
    padding: 5px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.credit-pill:hover {
    background: rgba(16, 185, 129, 0.28);
    transform: translateY(-1px);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.user-badge-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.82rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 50px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
}

@media (max-width: 768px) {
    .navbar {
        padding: 10px 0;
    }
    .nav-content {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .logo-row {
        justify-content: space-between;
        width: 100%;
    }
    .nav-links {
        justify-content: center;
        gap: 8px;
        width: 100%;
    }
    .container {
        padding: 0 12px;
        width: 100%;
        max-width: 100%;
    }
    .hero {
        padding: 24px 0 16px;
    }
    .hero-title {
        font-size: 1.6rem !important;
        line-height: 1.3;
        margin-bottom: 12px;
    }
    .hero-subtitle {
        font-size: 0.95rem !important;
        margin-bottom: 20px;
    }
    .glass-card {
        padding: 16px 12px !important;
        margin-bottom: 24px !important;
        border-radius: var(--radius-md) !important;
        width: 100%;
        max-width: 100%;
    }
    .stepper {
        flex-direction: row;
        gap: 4px;
        margin-bottom: 20px;
        justify-content: space-around;
    }
    .stepper::before {
        display: none !important; /* Hide floating line on mobile */
    }
    .step-item {
        font-size: 0.7rem;
        text-align: center;
    }
    .step-number {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.85rem !important;
    }
    .step-label {
        font-size: 0.7rem !important;
    }
    .pdf-positioner-container, .pdf-continuous-container {
        padding: 4px !important;
        max-width: 100% !important;
    }
    canvas.signature-pad {
        height: 170px !important;
    }
    .btn {
        width: 100%;
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    .signer-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .signer-card {
        padding: 14px !important;
    }
    .modal-card {
        padding: 16px !important;
        width: 96% !important;
        max-width: 96% !important;
    }
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    color: #fff;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 48px 0 32px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.hero-title {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 680px;
    margin: 0 auto 32px;
    line-height: 1.6;
}

.price-pill {
    display: inline-block;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #6ee7b7;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
}

/* Glass Card & Form */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-backdrop);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    margin-bottom: 48px;
    transition: border-color 0.3s;
}

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

/* Stepper */
.stepper {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    position: relative;
}

.stepper::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 40px;
    right: 40px;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 1;
}

.step-item {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.step-number {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #1e293b;
    border: 2px solid #334155;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: all 0.3s;
}

.step-item.active .step-number {
    background: var(--primary);
    border-color: #818cf8;
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.step-item.completed .step-number {
    background: var(--success);
    border-color: #34d399;
    color: #fff;
}

.step-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.step-item.active .step-label {
    color: #fff;
}

/* Upload Dropzone */
.dropzone {
    border: 2px dashed rgba(99, 102, 241, 0.4);
    background: rgba(15, 23, 42, 0.5);
    border-radius: var(--radius-md);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.dropzone-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 16px;
}

.uploaded-file-card {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
}

/* Upload Progress Bar */
.upload-progress-card {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(99, 102, 241, 0.5);
    border-radius: var(--radius-md);
    padding: 22px 24px;
    margin-top: 16px;
    display: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

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

.progress-filename {
    font-weight: 600;
    font-size: 0.95rem;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-percentage {
    font-weight: 700;
    font-size: 0.95rem;
    color: #818cf8;
}

.progress-bar-track {
    width: 100%;
    height: 10px;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6366f1 0%, #3b82f6 50%, #10b981 100%);
    border-radius: 999px;
    transition: width 0.15s ease-out;
}

.progress-status {
    font-size: 0.82rem;
    color: #94a3b8;
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
}

/* Form Controls */
.form-group {
    margin-bottom: 24px;
}

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

.form-control {
    width: 100%;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Signer Row */
.signer-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    position: relative;
}

.signer-grid {
    display: grid;
    grid-template-columns: 2fr 2fr 1.5fr 1.5fr auto;
    gap: 16px;
    align-items: center;
}

@media (max-width: 900px) {
    .signer-grid {
        grid-template-columns: 1fr;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px -8px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 10px;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* PIX Box */
.pix-box {
    text-align: center;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    padding: 32px;
}

.qr-code-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px auto;
}

.qr-code-img {
    width: 220px;
    height: 220px;
    display: block;
    margin: 0 auto;
    background: #fff;
    padding: 12px;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.pix-payload-input {
    font-family: monospace;
    font-size: 0.85rem;
    background: #090d16;
    color: #94a3b8;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    padding: 12px;
    width: 100%;
    resize: none;
}

/* Signature Pad Canvas */
.signature-canvas-wrapper {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-highlight);
    overflow: hidden;
    position: relative;
    margin-bottom: 16px;
}

@keyframes pulse {
    0% { opacity: 0.4; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0.4; transform: scale(0.95); }
}

canvas.signature-pad {
    width: 100%;
    height: 220px;
    display: block;
    cursor: crosshair;
}

/* Footer */
footer {
    margin-top: auto;
    padding: 32px 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* PIX Realtime Waiting Badge */
.pix-waiting-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(97, 248, 188, 0.1);
    border: 1px solid rgba(97, 248, 188, 0.35);
    color: #61f8bc;
    padding: 14px 28px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(97, 248, 188, 0.15);
}

.pix-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(97, 248, 188, 0.3);
    border-top-color: #61f8bc;
    border-radius: 50%;
    animation: pixSpin 0.8s linear infinite;
}

@keyframes pixSpin {
    to { transform: rotate(360deg); }
}

/* Mobile Responsive Optimizations */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    .hero-title {
        font-size: 1.7rem !important;
    }
    .summary-price-banner {
        flex-direction: column !important;
        align-items: stretch !important;
        text-align: center !important;
        padding: 16px !important;
        gap: 10px !important;
    }
    .summary-price-right {
        text-align: center !important;
        border-top: 1px dashed var(--border-color);
        padding-top: 10px;
    }
    .summary-price-banner #summaryTotalAmount {
        font-size: 1.8rem !important;
    }
    #positionerModal {
        padding: 10px !important;
    }
    #positionerModal > div {
        padding: 14px !important;
        border-radius: var(--radius-md) !important;
    }
    .pdf-positioner-container {
        padding: 6px !important;
        max-height: 420px !important;
    }
    .placed-tag-badge {
        font-size: 0.65rem !important;
        padding: 3px 8px !important;
        max-width: 140px !important;
        border-width: 1px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    .proc-card {
        padding: 16px !important;
    }
    .proc-card-header {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .proc-card-actions {
        text-align: left !important;
        margin-top: 12px !important;
    }
    .proc-card-actions > div {
        justify-content: flex-start !important;
    }
    .proc-card-actions .btn, .proc-card-actions a {
        flex: 1 1 auto;
        text-align: center;
        justify-content: center;
    }
}

/* History Table Base & Mobile Card Layout */
.history-table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.history-table th {
    background: rgba(15, 23, 42, 0.6);
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.history-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.9rem;
    color: #f8fafc;
    vertical-align: middle;
}

.history-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.history-actions-td {
    white-space: nowrap;
    text-align: right;
}

.history-actions-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 640px) {
    .history-table-wrapper {
        overflow-x: visible;
    }

    .history-table, 
    .history-table thead, 
    .history-table tbody, 
    .history-table th, 
    .history-table td, 
    .history-table tr {
        display: block;
    }

    .history-table thead {
        display: none;
    }

    .history-table tr {
        background: rgba(15, 23, 42, 0.85);
        border: 1px solid rgba(99, 102, 241, 0.25);
        border-radius: var(--radius-md);
        margin-bottom: 16px;
        padding: 16px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    }

    .history-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
        font-size: 0.88rem;
        text-align: right;
    }

    .history-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #94a3b8;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        text-align: left;
        margin-right: 12px;
    }

    .history-table td.history-actions-td {
        border-bottom: none;
        display: block !important;
        margin-top: 10px;
        padding-top: 12px;
        text-align: center;
    }

    .history-table td.history-actions-td::before {
        display: none;
    }

    .history-actions-wrapper {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
    }

    .history-actions-wrapper button,
    .history-table td.history-actions-td button {
        width: 100% !important;
        margin: 0 !important;
        justify-content: center !important;
        padding: 10px 16px !important;
        font-size: 0.85rem !important;
        display: flex !important;
        align-items: center !important;
    }

    .packages-grid {
        grid-template-columns: 1fr !important;
    }
}
