:root {
    --bg-color: #0f172a; /* Slate 900 */
    --surface-color: #1e293b; /* Slate 800 */
    --surface-color-light: #334155; /* Slate 700 */
    --text-primary: #f8fafc; /* Slate 50 */
    --text-secondary: #94a3b8; /* Slate 400 */
    --accent-color: #3b82f6; /* Blue 500 */
    --accent-hover: #2563eb; /* Blue 600 */
    --success-color: #10b981; /* Emerald 500 */
    --success-hover: #059669; /* Emerald 600 */
    --border-color: #334155;
    
    --radius-md: 8px;
    --radius-lg: 16px;
    
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

/* App Container - simulates a sleek card inside the iframe */
.app-container {
    width: 100%;
    max-width: 800px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--surface-color);
    box-shadow: var(--shadow-glass);
    position: relative;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}

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

.logo-area h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    background-color: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

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

/* Document Viewer */
.document-viewer {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-color: #000; /* Darker background behind PDF */
    position: relative;
}

.pdf-container {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 20px;
    min-height: 500px; /* fallback */
}

#pdfCanvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    background-color: white; /* PDF pages are usually white */
}

.pdf-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Footer & Actions */
.app-footer {
    padding: 20px 24px;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.security-notice {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.action-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
}

/* Buttons */
.btn {
    flex: 1;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    border: none;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.btn-primary:hover {
    background-color: var(--accent-hover);
}

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

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

.btn-secondary {
    background-color: var(--surface-color-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
}

.btn-icon:hover:not(:disabled) {
    background-color: var(--surface-color-light);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading Screen */
.loading-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--surface-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    gap: 16px;
    transition: opacity 0.3s ease;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* Modal / Glassmorphism */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 16px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.glass-effect {
    background: rgba(30, 41, 59, 0.85);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
}

.modal-content {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.btn-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-body p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Signature Pad Canvas Container */
.signature-wrapper {
    background-color: #fff;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    border: 2px dashed #cbd5e1;
}

#signaturePadCanvas {
    width: 100%;
    height: 200px;
    touch-action: none; /* Prevents scrolling while signing on mobile */
    cursor: crosshair;
}

.modal-footer {
    padding: 20px;
    display: flex;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .app-header {
        padding: 12px 16px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
    }
}
