:root {
    --primary: #3730a3;
    /* Royal Indigo */
    --primary-hover: #312e81;
    --secondary: #64748b;
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 30px;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

.app-logo span {
    color: var(--primary);
}

/* Layout */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

@media (max-width: 1024px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

/* Form Styles */
.form-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s;
    background: #fdfdfd;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 76, 92, 0.1);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.input-with-select {
    display: flex;
    gap: 8px;
}

.input-with-select select {
    width: 80px;
}

/* Voucher Toggle */
.voucher-toggle {
    display: flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 10px;
    margin-right: 16px;
}

.mode-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
}

.mode-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Policy Toggle */
.policy-toggle {
    display: flex;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 12px;
    gap: 8px;
}

.policy-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: var(--text-muted);
}

.policy-btn.active {
    background: white;
    color: #ef4444;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f8fafc;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Room Row Styles */
.room-row {
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 12px;
    position: relative;
}

.grid-table {
    display: grid;
    grid-template-columns: 1.5fr 1.5fr 0.8fr 0.8fr 1.2fr 0.8fr 1.5fr;
    gap: 8px;
}

.grid-table .form-group {
    margin-bottom: 0;
}

/* Preview Styles */
.preview-container {
    height: 100vh;
}

.preview-sticky {
    position: sticky;
    top: 20px;
}

/* PDF VOUCHER STYLES - REFINED LUXURY */
.voucher-paper {
    background: white;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 30px 40px;
    /* Reduced vertical padding */
    color: #1e293b;
    border-top: 10px solid var(--primary);
    box-shadow: var(--shadow-lg);
    line-height: 1.3;
    /* Tighter line height */
    min-height: auto;
    /* Remove min-height to avoid forcing empty space */
}

.hide-header .voucher-header {
    display: none !important;
}

.voucher-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 15px 25px;
    /* Reduced padding */
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 25px;
    /* Reduced margin */
}

.agency-logo-preview img {
    height: 60px;
    /* Smaller logo */
    object-fit: contain;
}

.header-right {
    text-align: center;
}

.agency-name {
    font-size: 22px;
    /* Smaller font */
    font-weight: 900;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.agency-details {
    font-size: 12px;
    /* Smaller font */
    color: #475569;
    font-weight: 600;
    margin-top: 2px;
}

.voucher-title {
    text-align: center;
    margin-bottom: 25px;
    /* Reduced margin */
}

.voucher-title h3 {
    font-size: 24px;
    /* Smaller font */
    font-weight: 900;
    color: var(--primary);
    letter-spacing: 3px;
    text-transform: uppercase;
}

.hotel-info-section {
    display: grid;
    grid-template-columns: 1fr 200px;
    /* Adjusted columns */
    gap: 20px;
    /* Reduced gap */
    margin-bottom: 25px;
    /* Reduced margin */
    background: #f8fafc;
    padding: 20px;
    /* Reduced padding */
    border-radius: 15px;
}

.hotel-text h4 {
    font-size: 19px;
    /* Smaller font */
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 10px;
    line-height: 1.2;
    letter-spacing: -0.2px;
}

.hotel-text p {
    font-size: 13px;
    /* Smaller font */
    margin-bottom: 6px;
    color: #334155;
}

.hotel-text strong {
    color: var(--primary);
    font-weight: 700;
    width: 90px;
    display: inline-block;
}

.hotel-image img {
    width: 200px;
    height: 130px;
    /* Smaller image */
    object-fit: cover;
    border-radius: 12px;
}

.guest-stay-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    /* Reduced gap */
    margin-bottom: 25px;
    /* Reduced margin */
}

.info-item {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
}

.guest-stay-grid .info-item:nth-child(1) {
    grid-column: span 2;
}

.guest-stay-grid .info-item:nth-child(2) {
    grid-column: span 1;
}

.guest-stay-grid .info-item.spacer {
    display: none;
}

.info-item label {
    display: block;
    font-size: 10px;
    /* Smaller font */
    color: #64748b;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 3px;
}

.info-item .val {
    font-size: 13px;
    /* Smaller font */
    font-weight: 700;
    color: #0f172a;
}

.guest-stay-grid .info-item:nth-child(4),
.guest-stay-grid .info-item:nth-child(5),
.guest-stay-grid .info-item:nth-child(6) {
    background: #eef2ff;
    padding: 10px;
    /* Reduced padding */
    border-radius: 10px;
    border: 1px solid #e0e7ff;
    border-bottom: none;
    text-align: center;
}

.guest-stay-grid .info-item:nth-child(4) label,
.guest-stay-grid .info-item:nth-child(5) label,
.guest-stay-grid .info-item:nth-child(6) label {
    color: var(--primary);
    margin-bottom: 4px;
}

.guest-stay-grid .info-item:nth-child(4) .val,
.guest-stay-grid .info-item:nth-child(5) .val,
.guest-stay-grid .info-item:nth-child(6) .val {
    font-size: 15px;
    /* Smaller font */
    color: var(--primary);
    font-weight: 800;
}

.table-header-bar {
    background: var(--primary);
    color: white;
    padding: 10px 15px;
    /* Slightly tighter */
    font-size: 14px;
    font-weight: 800;
    border-radius: 10px 10px 0 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.details-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e2e8f0;
    border-top: none;
}

.details-table th {
    background: #f1f5f9;
    color: var(--primary);
    font-size: 10px;
    /* Smaller font */
    text-transform: uppercase;
    font-weight: 800;
    padding: 10px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.details-table td {
    padding: 12px 10px;
    /* Reduced padding */
    text-align: center;
    font-size: 12px;
    /* Smaller font */
    font-weight: 600;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

.details-table th:first-child,
.details-table td:first-child,
.details-table th:nth-child(2),
.details-table td:nth-child(2),
.details-table th:nth-child(5),
.details-table td:nth-child(5) {
    white-space: nowrap;
}

.policy-preview-section {
    margin: 20px 0;
    /* Reduced margin */
}

.policy-content {
    background: #fff1f2;
    color: #b91c1c;
    padding: 12px 15px;
    /* Reduced padding */
    border-left: 4px solid #ef4444;
    border-radius: 4px;
    font-size: 13px;
    /* Smaller font */
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.notes-section {
    margin-top: 25px;
    /* Reduced margin */
    background: #f8fafc;
    padding: 20px;
    /* Reduced padding */
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.notes-label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.notes-content {
    font-size: 12px;
    /* Smaller font */
    color: #475569;
    line-height: 1.5;
}

.voucher-footer {
    margin-top: 30px;
    /* Reduced margin */
    text-align: center;
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
}

.wish {
    font-size: 14px;
    /* Smaller font */
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 5px;
}

.footer-links {
    font-size: 10px;
    /* Smaller font */
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@media (max-width: 768px) {
    .app-container {
        padding: 0 12px;
    }

    .main-header {
        flex-direction: column;
        align-items: center;
        gap: 16px;
        padding: 15px 0;
        margin-bottom: 20px;
    }

    .logo-section {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .main-header .actions {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 12px;
        align-items: center;
    }

    .voucher-toggle {
        margin-right: 0;
        width: 100%;
        max-width: 400px;
        display: flex;
    }

    .mode-btn {
        flex: 1;
        padding: 10px 8px;
        font-size: 13px;
        white-space: nowrap;
    }

    .btn-primary {
        width: 100%;
        max-width: 400px;
        justify-content: center;
        padding: 12px;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .grid-table {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .room-row {
        padding: 15px;
    }

    .card-header {
        padding: 15px;
    }

    .card-body {
        padding: 15px;
    }

    /* Prevent preview from clipping on small screens */
    .preview-container {
        overflow-x: auto;
        padding-bottom: 20px;
    }

    .voucher-paper {
        min-width: 600px;
        /* Allow horizontal scroll for PDF preview */
        transform: scale(0.9);
        /* Slight scale down */
        transform-origin: top left;
    }
}

/* Extra small screens fix */
@media (max-width: 480px) {
    .mode-btn {
        font-size: 12px;
        padding: 8px 4px;
    }

    .app-logo h1 {
        font-size: 18px;
    }
}

@media print {

    .form-container,
    .main-header {
        display: none !important;
    }

    .editor-layout {
        display: block;
    }

    .preview-container {
        height: auto;
    }

    .voucher-paper {
        box-shadow: none;
        border: none;
        padding: 20px;
        transform: none !important;
        width: 100% !important;
        min-width: 0 !important;
    }
}