/* Global Reset & Box Sizing */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

@font-face {
    font-family: 'Roboto';
    src: url('fonts/Roboto-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Roboto';
    src: url('fonts/Roboto-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'Roboto';
    src: url('fonts/Roboto-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

:root {
    --primary-color: #000000;
    --accent-color: #FF0000;
    /* Toshiba Red */
    --bg-color: #F5F7FA;
    --panel-bg: #FFFFFF;
    --text-color: #333333;
    --border-color: #E1E4E8;
    --input-bg: #F0F2F5;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);

    /* MFP Dimensions */
    --app-height: 100vh;
    /* Usually 600px on MFP */
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* App Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    max-width: 1024px;
    max-height: 600px;
    background: var(--panel-bg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* Control Panel (Left) */
.controls {
    width: 40%;
    height: 100%;
    padding: 2rem;
    border-right: 1px solid var(--border-color);
    background: #FFFFFF;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

/* Header Nav for Subpages */
.header-nav {
    margin-bottom: 0.5rem;
}

.back-link {
    display: inline-block;
    vertical-align: middle;
    text-decoration: none;
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link svg {
    vertical-align: middle;
    margin-right: 0.5rem;
}

.back-link:hover {
    color: var(--text-color);
}

header {
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

header p {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.2rem;
}

/* Form Styles */
#qrForm {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.form-row {
    margin-bottom: 1rem;
}

/* Input Row for side-by-side inputs */
.input-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.input-row .input-group {
    flex: 1;
    margin-bottom: 0;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.input-group input,
.input-group select {
    display: block;
    padding: 0.7rem 1rem;
    border: 2px solid transparent;
    background: var(--input-bg);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
    width: 100%;
}

.simple-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1rem;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #FFF;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.checkbox-group {
    margin-bottom: 1rem;
}

.checkbox-group input {
    display: inline-block;
    vertical-align: middle;
    width: auto;
    margin-right: 0.5rem;
}

.checkbox-group label {
    display: inline-block;
    vertical-align: middle;
    margin-bottom: 0;
}

/* Color Picker */
.color-options {
    margin-bottom: 1rem;
}

.color-btn {
    display: inline-block;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #FFF;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-right: 0.8rem;
}

.color-btn:active {
    transform: scale(0.9);
}

.color-btn.active {
    box-shadow: 0 0 0 2px var(--primary-color), 0 4px 8px rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

/* Actions */
.actions {
    margin-top: 1.5rem;
}

.btn-primary {
    display: block;
    width: 100%;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: background 0.2s, transform 0.1s;
}

.btn-primary svg {
    vertical-align: middle;
    margin-right: 0.8rem;
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Preview Area (Right) */
.preview-container {
    width: 60%;
    height: 100%;
    background: #E0E5EC;
    position: relative;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-wrapper {
    background: white;
    width: 100%;
    max-width: 360px;
    height: 509px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.preview-label {
    position: absolute;
    bottom: 1rem;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    color: #8898AA;
    font-weight: 500;
    letter-spacing: 1px;
}

/* A4 Page Layout (Displayed inside preview-wrapper) */
.a4-page {
    width: 100%;
    height: 100%;
    text-align: center;
    background: white;
    color: black;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.content-wrapper {
    width: 100%;
    height: 100%;
    border: 4px solid black;
    padding: 1.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#displayTitle {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    line-height: 1.2;
    text-transform: uppercase;
    word-break: break-word;
}

.qr-container {
    background: white;
    padding: 0.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

#qrcode img {
    max-width: 100%;
    height: auto !important;
    display: inline-block;
    max-height: 15rem;
}

#displaySubtitle {
    font-size: 1.1rem;
    font-weight: 400;
    color: #444;
}

.wifi-info {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: #333;
    line-height: 1.5;
    word-break: break-word;
}

.footer-branding {
    position: absolute;
    bottom: 1.5rem;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Landing Page */
.app-container.landing-mode {
    display: flex;
    align-items: center;
    justify-content: center;
}

.landing-container {
    max-width: 1000px;
    width: 100%;
    text-align: center;
    padding: 1rem;
}

.landing-header {
    text-align: center;
    margin-bottom: 2rem;
}

.landing-header h1 {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin-bottom: 0.2rem;
}

.landing-header p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 1.5rem;
}

.landing-nav {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    flex-wrap: wrap;
    width: 100%;
    margin: 0 auto;
}

.nav-card {
    background: white;
    width: 200px;
    height: 180px;
    padding: 1.5rem;
    border-radius: 12px;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    /* Toshiba Red Accent */
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.nav-card:hover {
    box-shadow: var(--shadow-md);
    background-color: var(--accent-color);
    color: white;
}

.nav-card:active {
    top: 1px;
}

.nav-card svg {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    display: inline-block;
}

.nav-card:hover svg {
    color: white;
}

.nav-card span {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

/* PRINT STYLES - CRITICAL */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    html,
    body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        background: white;
        overflow: hidden !important;
        /* Prevent second page */
    }

    /* Hide app container UI elements in print, only keep the preview */
    .app-container {
        display: block;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
        background: white;
    }

    .controls,
    .preview-label,
    .landing-container,
    .back-link,
    header {
        display: none !important;
    }

    .preview-container,
    .preview-container * {
        visibility: visible;
    }

    .preview-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        padding: 0;
        background: white;
    }

    .preview-wrapper {
        box-shadow: none;
        max-width: 100%;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .a4-page {
        width: 100%;
        height: 100%;
        padding: 0;
        position: relative;
        left: 0;
        top: 0;
        text-align: center;
    }

    .content-wrapper {
        border-width: 2px !important;
        /* Thinner for real print */
        height: 100%;
        position: relative;
    }

    #displayTitle {
        font-size: 36pt;
        /* Print units */
    }

    .wifi-info {
        font-size: 24pt;
        margin: 20mm 0;
    }

    #displaySubtitle {
        font-size: 18pt;
    }

    #qrcode img {
        width: 80mm !important;
        /* Fixed print size */
        height: 80mm !important;
        max-width: none !important;
        max-height: none !important;
        object-fit: contain;
    }
}