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

:root {
    --primary: #4F46E5;
    --primary-foreground: #FFFFFF;
    --secondary: #F1F5F9;
    --secondary-foreground: #1E293B;
    --accent: #F97316;
    --accent-foreground: #FFFFFF;
    --background: #F8FAFC;
    --foreground: #0F172A;
    --card: #FFFFFF;
    --card-foreground: #0F172A;
    --border: #E2E8F0;
    --muted: #F1F5F9;
    --muted-foreground: #64748B;
    --destructive: #EF4444;
    --ring: #4F46E5;
    --radius: 0.5rem;
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--foreground);
}

.logo img {
    height: 40px;
    width: auto;
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav a {
    text-decoration: none;
    color: var(--muted-foreground);
    font-weight: 500;
    transition: color 0.2s;
}

.nav a:hover, .nav a.active {
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: var(--primary) !important;
    color: var(--primary-foreground) !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background: var(--hover, #2563EB) !important;
}

.btn-secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
}

.btn-secondary:hover {
    background: var(--hover, #2563EB) !important;
    color: white !important;
}

.btn-accent {
    background: var(--accent);
    color: var(--accent-foreground);
}

.btn-accent:hover {
    background: var(--hover, #2563EB) !important;
    color: white !important;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--foreground);
}

.btn-outline:hover {
    background: var(--hover, #2563EB) !important;
    color: white !important;
    border-color: var(--hover, #2563EB) !important;
}

.btn-ghost {
    background: transparent;
    color: var(--foreground);
}

.btn-ghost:hover {
    background: var(--hover, #2563EB) !important;
    color: white !important;
}

/* Universal hover for all buttons */
.btn:hover {
    background: var(--hover, #2563EB) !important;
    color: #fff !important;
    opacity: 1;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

.card-image {
    aspect-ratio: 4/5;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-body {
    padding: 1.25rem;
}

.card-title {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.card-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

/* Hero Section */
.hero {
    padding: 5rem 0;
    text-align: left;
    background: linear-gradient(135deg, var(--background) 0%, var(--secondary) 100%);
}

.hero-content {
    max-width: 600px;
}

.hero h1 {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    letter-spacing: -0.04em;
}

.hero p {
    font-size: 1.25rem;
    color: var(--muted-foreground);
    margin-bottom: 2rem;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    padding: 3rem 0;
}

/* Customizer */
.customizer {
    display: flex;
    min-height: calc(100vh - 80px);
}

.customizer-sidebar {
    width: 320px;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    overflow-y: auto;
}

.customizer-canvas {
    flex: 1;
    background: var(--secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
}

.canvas-container {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.canvas-product {
    max-width: 100%;
    max-height: 70vh;
    display: block;
}

.canvas-print {
    position: absolute;
    cursor: move;
    border: 2px dashed transparent;
    transition: border-color 0.2s;
    touch-action: none;
}

.canvas-print:hover, .canvas-print.active {
    border-color: var(--primary);
}

.canvas-print img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border: 2px solid white;
    border-radius: 50%;
}

.resize-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }
.resize-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.resize-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.resize-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 0.75rem auto 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    width: fit-content;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--background);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

/* Image Grid (for selecting prints) */
.image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.image-option {
    aspect-ratio: 1;
    background: var(--secondary);
    border: 2px solid transparent;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.image-option:hover {
    border-color: var(--muted-foreground);
}

.image-option.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.image-option img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: var(--muted-foreground);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--foreground);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Section */
.section {
    padding: 4rem 0;
}

.section-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    color: var(--muted-foreground);
    margin-bottom: 2rem;
}

/* Footer */
.footer {
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 3rem 0;
    text-align: center;
    color: var(--muted-foreground);
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--background);
}

.upload-zone:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.upload-zone input {
    display: none;
}

.upload-zone i {
    font-size: 2rem;
    color: var(--muted-foreground);
    margin-bottom: 1rem;
}

/* 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: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card);
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted-foreground);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: #DCFCE7;
    color: #166534;
    border: 1px solid #BBF7D0;
}

.alert-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* Global touch and mobile improvements */
* { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; height: auto; }
input, select, textarea, button { font-size: 16px; }

/* Responsive */

/* Tablet - 769px to 1024px */
@media (max-width: 1024px) {
    .nav {
        gap: 1rem;
    }
    .nav a {
        font-size: 0.8rem;
    }
    .hero h1 {
        font-size: 2.75rem;
    }
    .section {
        padding: 3rem 0;
    }
    .customizer-sidebar {
        width: 260px;
    }
}

/* Mobile - up to 768px */
@media (max-width: 768px) {
    /* Typography */
    .hero h1 {
        font-size: 2rem;
    }
    .hero p {
        font-size: 1rem;
    }
    .section-title {
        font-size: 1.5rem;
    }
    .section-subtitle {
        font-size: 0.9rem;
    }

    /* Header */
    .header-inner {
        padding: 0.75rem 0.5rem;
        gap: 0.5rem;
    }
    .logo img {
        height: 32px;
    }
    .logo-text {
        font-size: 1.1rem;
    }
    .nav {
        display: none;
    }
    .mobile-menu-btn {
        display: inline-flex !important;
    }

    /* Sections */
    .section {
        padding: 2rem 0;
    }
    .container {
        padding: 0 0.75rem;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Prevent horizontal page overflow */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Hero */
    .hero {
        padding: 3rem 0;
    }
    .hero h1,
    .hero h1[style] {
        font-size: 2rem !important;
    }
    .hero p {
        font-size: 0.95rem;
    }

    /* Buttons */
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 0.875rem;
    }

    /* Product/Card Grids */
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .card-body {
        padding: 0.75rem;
    }
    .card-title {
        font-size: 0.9rem;
    }
    .card-price {
        font-size: 1rem;
    }

    /* Customizer */
    .customizer {
        display: block !important;
        flex-direction: unset;
        min-height: auto;
        overflow: hidden !important;
        max-width: 100vw;
        width: 100%;
    }
    .customizer-sidebar {
        width: 100% !important;
        max-width: 100vw;
        max-height: none;
        overflow-y: visible !important;
        overflow-x: hidden !important;
        border-right: none;
        border-bottom: 1px solid var(--border);
        position: relative;
        padding: 1rem;
        box-sizing: border-box;
    }
    .customizer-canvas {
        padding: 0.75rem;
        min-height: auto;
        width: 100% !important;
        max-width: 100vw;
        overflow: hidden !important;
        box-sizing: border-box;
    }
    .canvas-container {
        max-width: 100% !important;
        overflow: hidden !important;
        box-sizing: border-box;
    }
    .canvas-container img,
    .canvas-product {
        max-width: 100% !important;
        height: auto !important;
        max-height: 50vh;
    }
    .toolbar {
        display: flex !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 0.5rem !important;
        gap: 0.3rem !important;
        border-radius: 10px !important;
        justify-content: center !important;
        position: relative !important;
        bottom: auto !important;
        margin: 0.5rem 0 0 !important;
        overflow: hidden !important;
    }
    .toolbar > * {
        flex-shrink: 0;
    }
    .toolbar .btn-ghost.btn-sm,
    .toolbar button {
        padding: 0.4rem 0.5rem !important;
        font-size: 0.8rem !important;
        min-width: 34px !important;
    }
    .toolbar > span[style*="width:1px"],
    .toolbar > span[style*="width: 1px"] {
        display: none !important;
    }
    .toolbar > label[title="Opacity"] {
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
        margin-top: 0.3rem !important;
        padding-top: 0.3rem !important;
        border-top: 1px solid var(--border) !important;
    }
    .toolbar > label[title="Opacity"] input[type="range"] {
        width: 80px !important;
    }
    /* Side tabs (front/back) */
    #sideTabsBar,
    #sideTabsBar > div {
        width: 100% !important;
        max-width: 100% !important;
    }
    #sideTabsBar button {
        flex: 1;
        padding: 0.4rem 0.75rem !important;
        font-size: 0.8rem !important;
    }
    /* Unified curve panel */
    #unifiedCurvePanel {
        white-space: normal !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        text-align: center;
    }
    #unifiedCurvePanel input[type="range"] {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0.25rem;
        display: block;
    }
    /* Text controls grid */
    .text-add-section [style*="grid-template-columns: 1fr 70px 50px"] {
        grid-template-columns: 1fr 55px 40px !important;
        gap: 0.3rem !important;
    }
    #printTextEditor [style*="grid-template-columns: 1fr 70px 50px"] {
        grid-template-columns: 1fr 55px 40px !important;
        gap: 0.3rem !important;
    }

    /* Image Grid (print selector) */
    .image-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    /* Forms */
    .form-group {
        margin-bottom: 1rem;
    }

    /* Modal */
    .modal {
        width: 95%;
    }

    /* Contact two-column to single */
    .contact-grid {
        grid-template-columns: 1fr !important;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr !important;
        text-align: center;
    }
}

/* Small phones - up to 480px */
@media (max-width: 480px) {
    .hero h1,
    .hero h1[style] {
        font-size: 1.5rem !important;
    }
    .product-grid {
        grid-template-columns: 1fr;
    }
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    .logo-text {
        font-size: 0.95rem;
    }
    .section h2 {
        font-size: 1.35rem;
    }
    /* Customizer small phone fixes */
    .customizer-sidebar {
        padding: 0.75rem;
    }
    .customizer-sidebar h2 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    .customizer-canvas {
        padding: 0.5rem;
    }
    .canvas-product {
        max-height: 40vh;
    }
    .toolbar {
        gap: 0.2rem !important;
        padding: 0.35rem 0.4rem !important;
    }
    .toolbar .btn-ghost.btn-sm,
    .toolbar button {
        padding: 0.3rem 0.35rem !important;
        font-size: 0.7rem !important;
        min-width: 28px !important;
    }
    .toolbar > label[title="Opacity"] input[type="range"] {
        width: 60px !important;
    }
    /* Text controls single row */
    .text-add-section [style*="grid-template-columns"] {
        grid-template-columns: 1fr 50px 36px !important;
    }
    #printTextEditor [style*="grid-template-columns"] {
        grid-template-columns: 1fr 50px 36px !important;
    }
    /* Price summary compact */
    .customizer-sidebar [style*="Price Summary"] {
        padding: 0.75rem;
    }
    /* Tabs compact */
    .tabs .tab {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
    /* Upload zone compact */
    .upload-zone {
        padding: 1rem;
    }
    .upload-zone i {
        font-size: 1.5rem;
    }
    /* Order modal full width */
    .modal {
        width: 98%;
        margin: 0.5rem;
        max-height: 95vh;
    }
    /* Empty state compact */
    #emptyState {
        padding: 1.5rem !important;
    }
    #emptyState i {
        font-size: 2.5rem !important;
    }
}

/* ===== Additional Mobile/Tablet Fixes ===== */

/* Hero buttons wrap on mobile */
@media (max-width: 768px) {
    .flex.gap-4,
    .hero-content .flex {
        flex-wrap: wrap;
        gap: 0.5rem !important;
        justify-content: center;
    }
    .hero-content .btn-lg,
    .hero-content .btn {
        font-size: 0.78rem;
        padding: 0.6rem 1rem;
    }
    /* Hero inline h1 override */
    section[style*="linear-gradient"] h1 {
        font-size: 1.5rem !important;
    }
    section[style*="linear-gradient"] p {
        font-size: 0.9rem;
    }
    /* Footer CTA buttons wrap */
    footer .btn,
    footer a.btn {
        font-size: 0.78rem;
        padding: 0.5rem 0.75rem;
    }
    /* Footer grid single column */
    footer [style*="grid-template-columns: repeat(3"] {
        grid-template-columns: 1fr !important;
        text-align: center;
        gap: 1.5rem !important;
    }
    /* Footer credit text */
    footer p[style*="0.75rem"] {
        font-size: 0.7rem !important;
    }
    /* Calendar designer sidebar scroll */
    .cd-side {
        max-height: 300px;
        overflow-y: auto;
    }
    .cd-canvas {
        min-height: 250px;
    }
    /* Order success cards */
    div[style*="max-width:600px"] {
        padding: 2rem 1rem !important;
    }
    /* Admin sidebar */
    .admin-sidebar {
        width: 220px !important;
    }
}

@media (max-width: 480px) {
    .hero-content .btn-lg,
    .hero-content .btn {
        font-size: 0.72rem;
        padding: 0.5rem 0.75rem;
        width: 100%;
        justify-content: center;
    }
    .hero-content .flex {
        flex-direction: column;
        align-items: stretch;
    }
    section[style*="linear-gradient"] h1 {
        font-size: 1.25rem !important;
    }
    /* Calendar type cards */
    .cd-tg {
        grid-template-columns: 1fr !important;
    }
    /* Checkout modal */
    .cd-mdl {
        padding: 1rem !important;
    }
}
