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

:root {
    --bg-app: #f3f4f6;
    --bg-card: #ffffff;
    --primary: #6366f1;
    --primary-light: #e0e7ff;
    --primary-hover: #4f46e5;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-white: #ffffff;
    --border: #e5e7eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.15);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --font-app: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-app);
    min-height: 100vh;
    line-height: 1.5;
}

/* Auth Layout */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(circle at top right, var(--primary-light), var(--bg-app) 60%);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    backdrop-filter: blur(8px);
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: var(--text-white);
    border-radius: 50%;
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 20px;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 30px;
}

/* Layouts & Sidebar */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    text-decoration: none;
    color: var(--text-main);
}

.sidebar-logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: var(--text-white);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
}

.sidebar-brand-name {
    font-size: 20px;
    font-weight: 700;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-link:hover, .sidebar-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.main-content {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
}

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

.page-title {
    font-size: 28px;
    font-weight: 700;
}

/* Cards & Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-info h3 {
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
    font-weight: 600;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.data-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
}

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

.card-title {
    font-size: 18px;
    font-weight: 600;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-app);
    font-size: 14px;
    color: var(--text-main);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow), 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: var(--font-app);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: var(--text-white);
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.15);
}

.btn-primary:hover {
    box-shadow: 0 6px 12px rgba(99, 102, 241, 0.25);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--border);
    color: var(--text-main);
}

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

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

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

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

.btn-success:hover {
    background: #059669;
}

.btn-icon {
    padding: 8px;
    border-radius: 50%;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th, .table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 14px;
}

.table tbody tr:hover {
    background-color: var(--bg-app);
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 9999px;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-neutral {
    background: var(--border);
    color: var(--text-muted);
}

/* Alert */
.alert {
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Public Form Styles */
.public-layout {
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--bg-app) 300px);
}

.public-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 680px;
    overflow: hidden;
    position: relative;
}

.public-card-accent {
    height: 10px;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.public-card-header {
    padding: 40px 40px 20px;
}

.public-card-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-main);
}

.public-card-desc {
    font-size: 15px;
    color: var(--text-muted);
    white-space: pre-line;
}

.public-card-body {
    padding: 20px 40px 40px;
}

.form-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    transition: box-shadow 0.2s;
}

.form-item:focus-within {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.form-item-label {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    display: block;
}

.form-item-label .required-star {
    color: var(--danger);
    margin-left: 4px;
}

/* Custom inputs for Radio, Checkbox, Dropdowns */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.option-item input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.option-label {
    font-size: 14px;
    color: var(--text-main);
}

/* Signature Canvas */
.signature-area {
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: #f9fafb;
    overflow: hidden;
    position: relative;
    margin-bottom: 10px;
}

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

.signature-controls {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Form Builder Panel */
.builder-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.builder-workspace {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    align-items: start;
}

.builder-canvas {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.builder-field-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.builder-field-card:hover {
    box-shadow: var(--shadow-md);
}

.builder-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.builder-field-index {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
}

.builder-field-actions {
    display: flex;
    gap: 8px;
}

.builder-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    position: sticky;
    top: 20px;
    box-shadow: var(--shadow-sm);
}

.field-btn-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 15px;
}

.btn-field-type {
    background: var(--bg-app);
    color: var(--text-main);
    border: 1px solid var(--border);
    text-align: left;
    justify-content: flex-start;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 13px;
}

.btn-field-type:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* Modal Popup */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    max-width: 500px;
    width: 100%;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalScale 0.25s ease-out;
}

@keyframes modalScale {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}

/* Success Animations */
.success-checkmark {
    width: 80px;
    height: 80px;
    margin: 0 auto 30px;
}

.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: var(--success);
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke-width: 3;
    stroke: var(--success);
    fill: none;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

/* Copy Link Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1f2937;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive Design / Mobile View Support */
@media (max-width: 1024px) {
    .builder-workspace {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .builder-sidebar {
        position: static;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 20px;
    }

    .sidebar-brand {
        margin-bottom: 20px;
    }

    .sidebar-menu {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 15px;
    }

    .sidebar-link {
        padding: 8px 12px;
        font-size: 13px;
    }

    .sidebar-footer {
        margin-top: 0;
        padding-top: 15px;
        border-top: none;
        display: flex;
        justify-content: flex-end;
    }

    .main-content {
        padding: 20px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .page-header .btn {
        width: 100%;
    }

    .public-layout {
        padding: 20px 10px;
    }

    .public-card-header {
        padding: 30px 20px 15px;
    }

    .public-card-title {
        font-size: 26px;
    }

    .public-card-body {
        padding: 15px 20px 30px;
    }

    .form-item {
        padding: 16px;
        margin-bottom: 16px;
    }

    .builder-field-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .builder-field-actions {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .sidebar-menu {
        flex-direction: column;
        width: 100%;
    }

    .sidebar-link {
        width: 100%;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .signature-canvas {
        height: 150px;
    }
}
