/* Century Gothic Font Family */
@font-face {
    font-family: 'Century Gothic';
    src: url('../fonts/gothic.TTF') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Century Gothic';
    src: url('../fonts/gothic-bold.TTF') format('truetype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'Century Gothic';
    src: url('../fonts/gothic-italic.TTF') format('truetype');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'Century Gothic';
    src: url('../fonts/gothic-bolditalic.TTF') format('truetype');
    font-weight: bold;
    font-style: italic;
}

:root {
    /* Colors - Light Theme (Modern Pastel Palette) */
    --bg-primary: #fafbfc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f4f8;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-muted: #a0aec0;
    --border-color: #e2e8f0;

    /* Accent Colors - Soft Pastel with Good Contrast */
    --accent-primary: #5c7cfa;
    /* Soft Blue - Primary actions */
    --accent-primary-hover: #4263eb;
    --accent-secondary: #845ef7;
    /* Soft Purple - Secondary */
    --accent-success: #51cf66;
    /* Soft Green - Success/Confirm */
    --accent-success-hover: #40c057;
    --accent-warning: #fcc419;
    /* Soft Yellow/Amber - Warning */
    --accent-warning-hover: #fab005;
    --accent-danger: #ff6b6b;
    /* Soft Red - Danger/Delete */
    --accent-danger-hover: #fa5252;
    --accent-info: #22d3ee;
    /* Soft Cyan - Info */
    --accent-ai: #845ef7;
    /* Soft Purple - AI */
    --accent-ai-hover: #7048e8;

    /* Shadows - Softer */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-primary-hover);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Auth Layout */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-tertiary);
}

.auth-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 450px;
    border: 1px solid var(--border-color);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .logo {
    font-size: 32px;
    margin-bottom: 8px;
}

.auth-header h1 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 38px;
    /* Adjust based on label height + padding */
    cursor: pointer;
    color: var(--text-secondary);
    z-index: 10;
}

.password-toggle:hover {
    color: var(--text-primary);
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Checkbox styling with primary color */
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--accent-primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-success {
    background: var(--accent-success);
    color: white;
}

.btn-success:hover {
    background: var(--accent-success-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-warning {
    background: var(--accent-warning);
    color: white;
}

.btn-warning:hover {
    background: var(--accent-warning-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-info {
    background: var(--accent-info);
    color: white;
}

.btn-info:hover {
    background: #0ea5e9;
    /* slightly darker cyan, variable not defined for hover info */
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-ai {
    background: var(--accent-ai);
    color: white;
}

.btn-ai:hover {
    background: var(--accent-ai-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background: var(--accent-danger-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: width 0.3s ease;
    z-index: 100;
}

.sidebar.collapsed {
    width: 80px;
    padding: 20px 10px;
}

.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .sidebar-nav span:last-child {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding-bottom: 20px;
}

.sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .user-profile-summary {
    display: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.sidebar-header .logo {
    font-size: 24px;
}

.sidebar-header h2 {
    font-size: 16px;
    color: var(--text-primary);
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background: rgba(92, 124, 250, 0.1);
    color: var(--accent-primary);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 16px;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 80px;
}

/* Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.page-header h1 {
    font-size: 28px;
    color: var(--text-primary);
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 16px;
}

.card-body {
    padding: 20px;
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.template-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.template-card-preview {
    height: 160px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--text-muted);
}

.template-card-content {
    padding: 20px;
}

.template-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.template-card-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.template-card-actions {
    display: flex;
    gap: 8px;
}

.template-card-actions .btn {
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.template-card-actions .btn-sm {
    padding: 0 12px;
    height: 32px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    margin-bottom: 16px;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--accent-warning);
}

@media (max-width: 768px) {
    .pdf-preview-container {
        min-height: 300px !important;
    }

    /* Profile Page Mobile */
    .profile-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.toast {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.3s ease;
}

.toast.success {
    border-left-color: var(--accent-success);
}

.toast.error {
    border-left-color: var(--accent-danger);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* PDF Editor Specific */
.editor-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - 140px);
}

.editor-canvas-container {
    flex: 1;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    overflow: auto;
    position: relative;
}

.editor-canvas-wrapper {
    padding: 20px;
    display: flex;
    justify-content: center;
}

.editor-sidebar {
    width: 350px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.editor-toolbar {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.field-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.field-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.field-item:hover {
    border-color: var(--accent-primary);
}

.field-item.active {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.field-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.field-item-label {
    font-weight: 500;
    font-size: 14px;
}

.field-item-type {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Selection Box on PDF */
.selection-box {
    position: absolute;
    border: 2px dashed var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
    cursor: move;
}

.selection-box.active {
    border-style: solid;
    background: rgba(59, 130, 246, 0.2);
}

.selection-box .resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent-primary);
    border-radius: 50%;
}

.selection-box .resize-handle.se {
    right: -5px;
    bottom: -5px;
    cursor: se-resize;
}

/* Profile Page Grid */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    /* Reverted to 16px */
}

/* Original desktop signature wrapper style (inline-block behavior) */
.signature-wrapper {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    overflow: hidden;
    display: inline-block;
    width: auto;
}

/* Public Form Layout */
.public-form-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
    height: 100%;
}


/* AI Chat Widget */
.ai-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.ai-widget-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-ai);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 24px;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.ai-widget-toggle:hover {
    transform: scale(1.1);
}

.ai-chat-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    height: 500px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

/* PDF Preview Container */
.pdf-preview-container {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    min-height: 680px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    /* Changed to auto for scrolling */
}

.ai-chat-panel.active {
    display: flex;
}

.ai-chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.ai-message {
    margin-bottom: 16px;
}

.ai-message.user {
    text-align: right;
}

.ai-message-content {
    display: inline-block;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    max-width: 80%;
}

.ai-message.user .ai-message-content {
    background: var(--accent-primary);
    color: white;
}

.ai-message.assistant .ai-message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.ai-chat-input {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

.ai-chat-input input {
    flex: 1;
}

/* User Dropdown */
.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    display: none;
    z-index: 100;
}

.user-dropdown-menu.active {
    display: block;
}

.user-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.user-dropdown-menu a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Responsive */
/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 16px;
    }

    .sidebar-header h2,
    .sidebar-nav span:last-child {
        display: none;
    }

    .sidebar-header {
        justify-content: center;
    }

    .sidebar-nav a {
        justify-content: center;
        padding: 12px;
    }

    .main-content {
        margin-left: 80px;
    }

    .user-profile-summary {
        display: none;
    }

    .collapsed-logout,
    .collapsed-lang {
        display: block !important;
    }
}

/* Share Panel Responsive */
.share-panel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    flex-direction: column;
}

.share-panel.active {
    display: flex !important;
}

@media (max-width: 480px) {
    .share-panel {
        width: 100% !important;
    }
}

/* Global Responsive Table Stylings */
.responsive-table {
    width: 100%;
    border-collapse: collapse;
}

.responsive-table th,
.responsive-table td {
    padding: 12px 16px;
    font-size: 14px !important;
    /* Force 14px font size globally */
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px !important;
        padding: 20px;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-header h2,
    .sidebar-nav span:last-child {
        display: inline;
    }

    .sidebar-header {
        justify-content: flex-start;
    }

    .sidebar-nav a {
        justify-content: flex-start;
        padding: 12px 16px;
    }

    .user-profile-summary {
        display: block;
    }

    .collapsed-logout,
    .collapsed-lang {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
        width: 100%;
    }

    .template-grid {
        grid-template-columns: 1fr;
    }

    .editor-container {
        flex-direction: column;
        height: auto;
    }

    .editor-sidebar {
        width: 100%;
        height: 500px;
    }

    .editor-canvas-container {
        height: 500px;
    }

    /* Mobile Responsive Signature */
    .signature-wrapper {
        display: block;
        width: 100%;
    }

    .signature-wrapper canvas {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 3/2;
        /* Maintain proportional aspect ratio */
        cursor: crosshair;
        display: block;
        touch-action: none;
    }



    /* Responsive Table (Card View) */
    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td,
    .responsive-table th {
        display: block;
        width: 100%;
        font-size: 14px;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tr {
        margin-bottom: 0;
        background: transparent;
        border: none;
        border-bottom: 10px solid var(--bg-tertiary);
        /* Thicker separator to distinguish users without full card gap */
        border-radius: 0;
        padding: 16px;
    }

    .responsive-table tr:last-child {
        border-bottom: none;
    }

    .responsive-table td {
        text-align: right;
        padding: 8px 0;
        border-bottom: 1px solid var(--border-color);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .responsive-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
        justify-content: space-between;
        /* Align label left, buttons right */
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        text-align: left;
        margin-right: 16px;
    }

    /* Standard tables fallback */
    table:not(.responsive-table) {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Preview Modal */
    .preview-grid {
        grid-template-columns: 1fr !important;
        padding: 16px !important;
    }

    .modal {
        width: 95%;
        max-width: 95%;
        margin: 10px;
    }

    #history-overlay,
    #share-overlay {
        width: 100% !important;
    }

    /* Public Form Mobile */
    .public-form-grid {
        grid-template-columns: 1fr !important;
        height: auto !important;
        display: flex !important;
        flex-direction: column-reverse;
        /* PDF on top or bottom? Let's put inputs first (bottom in column-reverse) or PDF first? Usually inputs first is better for "filling". But user needs to see PDF to fill. Let's do Standard column flex. */
        flex-direction: column !important;
    }

    .public-form-grid>.card {
        height: auto !important;
        min-height: 500px;
    }

    /* Hide PDF preview on very small screens or make it collapsible? 
       For now, let's keep it stacked. 
    */

    .page-header h1 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    .auth-card,
    .card {
        padding: 20px !important;
    }

    .card-header {
        padding: 16px 16px 16px 16px !important;
    }

    .dashboard .card-body.no-padding-mobile,
    .no-padding-mobile {
        padding: 0 !important;
    }

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .btn-lg {
        padding: 10px 20px;
        font-size: 14px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 12px;
    }

    .page-header h1 {
        font-size: 18px !important;
    }

    .page-header>div {
        width: 100%;
        justify-content: space-between;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-control {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Adjust toast position */
    .toast-container {
        width: 90%;
        left: 5%;
        transform: translateX(0);
    }

    .toast {
        width: 100%;
        padding: 12px 16px;
        font-size: 13px;
    }

    .template-card-preview {
        height: 120px;
        /* Smaller preview on mobile */
    }

    .template-card-preview i {
        width: 32px !important;
        height: 32px !important;
    }
}

/* Public Form Header Mobile Optimization */
.public-form-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
}

.public-form-header-content {
    max-width: 1920px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title-group .header-icon {
    font-size: 24px;
    display: flex;
    align-items: center;
}

.header-title-group .header-icon i {
    width: 24px;
    height: 24px;
}

.header-title-group h1 {
    font-size: 18px;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 8px;
}

@media (max-width: 768px) {
    .public-form-header {
        padding: 12px 16px;
    }

    .public-form-header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .header-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .header-actions .btn {
        padding: 8px 4px;
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        height: auto;
        min-height: 48px;
    }

    .header-actions .btn i {
        margin: 0 0 4px 0 !important;
    }

    /* Date Input Mobile Optimization */
    input[type="date"] {
        min-height: 44px;
        font-size: 16px !important;
        /* Prevent zoom */
        display: block;
        width: 100%;
        padding: 8px 12px;
    }

    /* Ensure form-control in general are touch-friendly */
    .form-control {
        font-size: 16px;
    }
}