:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --accent: #f59e0b;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-sub: #475569;
    --border: #e2e8f0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

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

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
aside {
    width: 280px;
    background: #0f172a;
    color: white;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 3.5rem;
    padding-left: 0.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
}

.logo-text {
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav ul {
    list-style: none;
}

nav li {
    padding: 0.9rem 1.25rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    color: #94a3b8;
    font-weight: 500;
}

nav li i {
    font-size: 1.1rem;
}

nav li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

nav li.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.user-profile {
    margin-top: auto;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-info span {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
}

.user-info a {
    font-size: 0.75rem;
    color: #94a3b8;
    text-decoration: none;
}

/* Main Content */
main {
    flex: 1;
    margin-left: 280px;
    padding: 3rem 4rem;
    max-width: 1400px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 3rem;
    animation: fadeIn 0.6s ease-out;
}

.header-title h2 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.header-title p {
    color: var(--text-sub);
    font-size: 1.05rem;
}

/* Auth Pages */
.auth-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, #f8fafc, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.auth-card {
    background: white;
    padding: 3.5rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.5s ease-out;
}

.auth-card h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    text-align: center;
}

.auth-card p {
    text-align: center;
    color: var(--text-sub);
    margin-bottom: 2.5rem;
}

.form-floating {
    margin-bottom: 1.25rem;
}

.form-floating label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 0.5rem;
    padding-left: 4px;
}

.form-floating input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s;
    background: #f8fafc;
}

.form-floating input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.auth-btn {
    width: 100%;
    padding: 1.1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 1rem;
}

.auth-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.auth-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-sub);
}

.auth-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    margin-left: 6px;
}

/* Buttons */
.btn-primary {
    padding: 0.8rem 1.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
}

.btn-secondary {
    padding: 0.8rem 1.75rem;
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f1f5f9;
}

/* Cards & Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 2rem;
}

.glass-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    border: 1px solid var(--border);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.glass-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(37, 99, 235, 0.3);
}

/* Data Tables */
.table-container {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-top: 1.5rem;
    padding: 0; /* Ensure no padding */
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    border: none;
    font-size: 0.95rem;
    text-align: left;
}

th {
    background: #f8fafc;
    padding: 1rem 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    vertical-align: middle;
}

td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #f9fafb;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-draft { background: #f1f5f9; color: #475569; }
.status-sent { background: #eff6ff; color: #2563eb; }
.status-pending { background: #fffbeb; color: #d97706; }
.status-completed { background: #f0fdf4; color: #16a34a; }
.status-expired { background: #fef2f2; color: #dc2626; }

.action-group {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.1rem;
}

.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

.btn-icon.delete:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-sheet {
    background: white;
    width: 90%;
    max-width: 680px;
    border-radius: var(--radius-lg);
    padding: 3.5rem;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-sheet.fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    padding: 2rem !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    display: flex;
    flex-direction: column;
}

/* Fullscreen Editor Layout */
.editor-main-layout {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0; /* Critical for inner scrolling */
    margin-top: 1rem;
}

.editor-sidebar {
    width: 260px;
    background: #f1f5f9;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 100%;
    gap: 1rem;
}

.editor-sidebar::-webkit-scrollbar {
    width: 6px;
}

.editor-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.editor-canvas-workspace {
    flex: 1;
    background: #e2e8f0;
    border-radius: var(--radius-md);
    overflow: auto;
    position: relative;
    padding: 40px 20px; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    border: 1px solid var(--border);
    gap: 30px;
}

.canvas-container {
    position: relative;
    background: white;
    box-shadow: var(--shadow-lg);
    border: 1px solid #94a3b8;
    transform-origin: top center;
}

.placed-field {
    position: absolute;
    background: rgba(37, 99, 235, 0.1);
    border: 1.5px solid var(--primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    cursor: move;
    z-index: 10;
    backdrop-filter: blur(2px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    user-select: none;
    transition: background 0.2s, box-shadow 0.2s;
    pointer-events: auto;
}

/* Signature Pad */
.signature-surface {
    background: #f8fafc;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    margin: 2rem 0;
    position: relative;
    cursor: crosshair;
}

canvas {
    width: 100% !important;
    height: 240px !important;
    touch-action: none;
}

/* Editor Specifics */
.draggable-field {
    padding: 0.6rem 0.8rem; /* Smaller padding */
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    cursor: grab;
    font-size: 0.85rem; /* Smaller font */
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.draggable-field i {
    font-size: 1rem; /* Smaller icon */
    color: var(--primary);
    width: 20px;
    text-align: center;
}

.draggable-field:hover {
    transform: translateX(5px);
    border-color: var(--primary);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.1);
    background: #eff6ff;
}

/* Properties Panel active state */
.properties-panel {
    display: none;
}
.properties-panel.active {
    display: flex;
}

.placed-field:hover, .placed-field.active {
    background: rgba(37, 99, 235, 0.2);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.4);
    z-index: 100;
}

.placed-field.active {
    border-color: #1e40af;
    background: rgba(37, 99, 235, 0.25);
}

.resizer {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border: 2px solid white;
    position: absolute;
    right: -6px;
    bottom: -6px;
    cursor: nwse-resize;
    border-radius: 50%;
    display: none;
    z-index: 110;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.placed-field.active .resizer {
    display: block;
}

.field-label-tag {
    position: absolute;
    top: -20px;
    left: 0;
    font-size: 10px;
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px 4px 0 0;
    white-space: nowrap;
}

/* Sidebar Section Headers */
.sidebar-header {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--secondary);
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.properties-panel {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    margin-top: 1rem;
    display: none; /* Only show when field active */
}

.properties-panel.active {
    display: block;
}

.placed-field .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    cursor: pointer;
}

/* Signer Input Styling */
.signer-input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    text-align: center;
    padding: 2px;
}

.signer-input:focus {
    outline: none;
    background: rgba(255,255,255,0.8);
}
