:root {
    --bg-color: #0f172a;
    --card-bg: rgba(20, 25, 40, 0.45);
    --border-color: rgba(255, 255, 255, 0.12);
    --border-highlight: rgba(255, 255, 255, 0.25);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-glow: rgba(59, 130, 246, 0.4);
    --success-color: #10b981;
    --success-hover: #34d399;
    --danger-color: #f43f5e;
    --danger-hover: #fb7185;
    --warning-color: #f59e0b;
    --focus-ring: rgba(59, 130, 246, 0.5);
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Aurora Background */
    background: linear-gradient(-45deg, #0f172a, #1e1b4b, #0f3d3e, #312e81, #1e1b4b);
    background-size: 400% 400%;
    animation: gradientBG 20s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* NAVBAR (Floating Pill Design) */
.navbar {
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 1.5rem;
    z-index: 100;
    margin: 0 auto 2rem auto;
    width: 95%;
    max-width: 900px;
    border-radius: 50px;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #60a5fa, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(96, 165, 250, 0.2);
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0.6rem 1.25rem;
    border-radius: 30px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

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

/* CONTAINER */
.view-container {
    flex: 1;
    padding: 1rem 2rem 3rem 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    animation: fadeInScale 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.hidden {
    display: none !important;
}

/* CARDS & GLASS PANELS */
.card, .glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    padding: 3rem;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.1);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease, border-color 0.4s ease;
}

.card:hover, .glass-panel:hover {
    box-shadow: 0 40px 80px -12px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.2);
    border-color: var(--border-highlight);
}

.form-card {
    width: 100%;
    max-width: 650px;
}

.full-width {
    width: 100%;
    max-width: 1300px;
}

header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

header p {
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    font-size: 1.1rem;
    font-weight: 400;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}
.flex-wrap {
    flex-wrap: wrap;
    gap: 1rem;
}

/* FORMS & INPUTS (Modernized) */
.form-group {
    margin-bottom: 1.75rem;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.form-group:focus-within label {
    color: var(--accent-hover);
}

.form-control {
    width: 100%;
    padding: 1rem 1.25rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.05rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.form-control::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-hover);
    box-shadow: 0 0 0 4px var(--focus-ring), inset 0 2px 4px rgba(0,0,0,0.1);
    background: rgba(15, 23, 42, 0.8);
}

/* Validation Error Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.input-error {
    border-color: var(--danger-color) !important;
    box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.2) !important;
    animation: shake 0.4s ease;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.25rem center;
    padding-right: 3rem;
}

select.form-control option {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}
.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

/* SIGNATURE PAD */
.signature-pad {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    cursor: crosshair;
    transition: all 0.3s ease;
    touch-action: none; /* prevent scrolling when drawing */
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
}

.signature-pad.active-pad {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--focus-ring), inset 0 2px 10px rgba(0,0,0,0.1);
}

.signature-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.clear-sig-btn {
    align-self: flex-start;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
}

/* RECAP CONTROLS */
.recap-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 1.25rem;
    color: var(--text-secondary);
}

.search-box input {
    padding-left: 3rem;
    width: 280px;
    border-radius: 30px; /* pill shape for search */
}

/* BUTTONS (Modernized) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    border-radius: 12px;
    font-weight: 700;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover { 
    transform: translateY(-3px); 
    box-shadow: 0 8px 25px var(--accent-glow); 
    border-color: rgba(255,255,255,0.2);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-hover) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}
.btn-success:hover { 
    transform: translateY(-3px); 
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--danger-hover) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3);
}
.btn-danger:hover { 
    transform: translateY(-3px); 
    box-shadow: 0 8px 25px rgba(244, 63, 94, 0.4);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}
.btn-secondary:hover { 
    background-color: rgba(255, 255, 255, 0.1); 
    transform: translateY(-2px);
    border-color: var(--border-highlight);
}

.btn-block { width: 100%; padding: 1.1rem; font-size: 1.1rem; border-radius: 16px; }

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2.5rem;
}

/* EDITOR BOX */
.editor-box {
    background: rgba(15, 23, 42, 0.3);
    border: 1px dashed var(--border-highlight);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2.5rem;
    transition: background 0.3s ease;
}
.editor-box:hover {
    background: rgba(15, 23, 42, 0.5);
}
.editor-box h3 { margin-bottom: 1.5rem; font-size: 1.25rem; font-weight: 700; }

/* FIELD LIST */
.fields-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.field-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 1.25rem 1.75rem;
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.field-item:hover {
    transform: translateY(-2px) scale(1.01);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-highlight);
    box-shadow: 0 10px 20px -5px rgba(0,0,0,0.2);
}
.field-info strong { display: block; font-size: 1.15rem; margin-bottom: 0.3rem; font-weight: 700; }
.field-info span { font-size: 0.9rem; color: var(--text-secondary); }

/* TABLE (Modernized) */
.table-container {
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    max-height: 550px; /* Internal scroll */
    box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
th, td { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-color); }
th { 
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    color: var(--text-secondary); 
    font-weight: 700; 
    font-size: 0.85rem; 
    text-transform: uppercase; 
    letter-spacing: 0.08em; 
    position: sticky; 
    top: 0; 
    z-index: 10;
}
tbody tr { transition: background-color 0.2s ease; }
tbody tr:hover { background-color: rgba(255, 255, 255, 0.04); }
td:first-child, th:first-child { padding-left: 2rem; }
td:last-child, th:last-child { padding-right: 2rem; }

td img.sig-thumb { 
    height: 45px; 
    background: white; 
    border-radius: 6px; 
    padding: 3px; 
    cursor: zoom-in;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--border-color);
}
td img.sig-thumb:hover {
    transform: scale(2.5);
    box-shadow: 0 10px 25px rgba(0,0,0,0.6);
    position: relative;
    z-index: 20;
    border-color: var(--accent-color);
}

/* MESSAGES */
.message { padding: 1.25rem; border-radius: 12px; margin-top: 1.5rem; text-align: center; font-weight: 600; animation: fadeInScale 0.3s ease; }
.message.success { background: rgba(16, 185, 129, 0.15); color: var(--success-hover); border: 1px solid rgba(16, 185, 129, 0.3); }
.message.error { background: rgba(244, 63, 94, 0.15); color: var(--danger-hover); border: 1px solid rgba(244, 63, 94, 0.3); }

/* EXPORT MODAL & LOGIN STYLES */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(28px);
    border: 1px solid var(--border-highlight);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6);
}

/* LOGIN VIEW STYLES */
.login-bg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    /* Aurora Background is already on body, login-bg just needs positioning */
    background: transparent; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 50;
}

.login-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #60a5fa, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    color: #94a3b8;
    margin-bottom: 2.5rem;
    font-size: 1.1rem;
}

.login-options {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.login-btn {
    padding: 1.25rem;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 16px;
}

.login-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.login-actions .btn {
    flex: 1;
}

/* Scrollbar customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
