/* ===== GUWALLI.COM - MOBILE FIRST ===== */

:root {
    --primary: #1a1a1a;
    --secondary: #8b7355;
    --accent: #d4a574;
    --light: #f8f6f3;
    --white: #ffffff;
    --dark: #2c2c2c;
    --gray: #6b7280;
    --gray-light: #e5e0da;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 2px 15px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--light);
    color: var(--primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

a { color: var(--secondary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent); }

img { max-width: 100%; height: auto; display: block; }

button, input, select, textarea { font-family: inherit; font-size: 16px; }

.container {
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 12px;
}

/* ===== HEADER (MOBILE FIRST) ===== */
.site-header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 0;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: nowrap;
}
.logo { flex-shrink: 0; display: flex; align-items: center; }
.logo img { height: 32px; width: auto; }

.mobile-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    order: 3;
}
.mobile-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--primary);
    transition: var(--transition);
}

.main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    flex-direction: column;
    padding: 0;
    box-shadow: var(--shadow);
    z-index: 99;
}
.main-nav.active { display: flex; }
.main-nav a {
    color: var(--primary);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--gray-light);
    width: 100%;
}
.main-nav a:active { background: var(--light); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    order: 2;
}

.cart-link {
    position: relative;
    color: var(--primary);
    display: flex;
    align-items: center;
    padding: 6px;
}
.cart-link svg { width: 22px; height: 22px; }
.cart-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--accent);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.user-dropdown { position: relative; }
.user-btn {
    background: none;
    border: 1.5px solid var(--gray-light);
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.75rem;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    z-index: 50;
}
.user-dropdown:hover .dropdown-menu,
.user-dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 0.7rem 1.25rem; color: var(--primary); font-size: 0.9rem; }

.header-actions > a.btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    min-height: 44px;
    -webkit-appearance: none;
}
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; min-height: 36px; }
.btn-primary {
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    color: var(--white);
    box-shadow: 0 4px 15px rgba(139,115,85,0.3);
}
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
    background: var(--white);
    color: var(--secondary);
    border: 2px solid var(--secondary);
}
.btn-danger { background: var(--error); color: var(--white); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ===== ALERTS ===== */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-weight: 500;
    font-size: 0.9rem;
}
.alert-success { background: #ecfdf5; color: #065f46; border-left: 4px solid var(--success); }
.alert-error { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--error); }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 4px solid var(--warning); }

/* ===== HERO ===== */
.hero {
    text-align: center;
    padding: 2rem 0 1.5rem;
}
.hero h1 { font-size: 1.75rem; margin-bottom: 0.75rem; font-weight: 700; }
.hero p { font-size: 0.95rem; color: var(--gray); max-width: 600px; margin: 0 auto 1.5rem; }

/* ===== SECTION ===== */
.site-main { padding: 1rem 0; min-height: 60vh; }
.section { padding: 1.5rem 0; }
.section-title {
    font-size: 1.3rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.section-title::before {
    content: '';
    width: 4px;
    height: 24px;
    background: var(--accent);
    border-radius: 2px;
    flex-shrink: 0;
}

/* ===== CARDS & GRID ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}
.card-img { width: 100%; height: 180px; object-fit: cover; }
.card-body { padding: 1rem; }
.card-title { font-size: 1rem; margin-bottom: 0.4rem; font-family: 'Playfair Display', serif; font-weight: 600; }
.card-category { font-size: 0.75rem; color: var(--gray); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.5px; }
.card-price { font-size: 1rem; font-weight: 700; color: var(--secondary); }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr; }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

/* ===== FRAME CARD ===== */
.frame-card { cursor: pointer; }
.frame-card .card-img { height: 160px; }

/* ===== PRODUCT PAGE ===== */
.product-layout {
    display: block;
    padding: 0.5rem 0;
    width: 100%;
}
.product-preview,
.product-info {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    width: 100%;
    display: block;
    position: static;
    float: none;
    clear: both;
    margin: 0 0 1.5rem 0;
    box-sizing: border-box;
}
.product-info { margin-bottom: 2rem; }

.pp-title { font-size: 1.2rem; margin-bottom: 0.85rem; }
.pp-block { margin-top: 1.25rem; display: block; width: 100%; }
.pi-title { font-size: 1.5rem; margin-bottom: 0.5rem; font-family: 'Playfair Display', serif; }
.pi-desc { color: var(--gray); margin-bottom: 1.25rem; font-size: 0.9rem; }
.pi-block { margin-bottom: 1.25rem; display: block; width: 100%; }

#photoInput { display: none; }
.uploaded-preview { display: none; width: 100%; border-radius: 8px; margin-top: 0.5rem; }
.uploaded-preview.show { display: block; }
.upload-area.hidden { display: none; }
.change-photo-btn { display: none; margin-top: 0.5rem; }
.change-photo-btn.show { display: inline-flex; }

.bg-thumb.bg-none {
    background: #e8e4df;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #999;
    cursor: pointer;
    height: 60px;
    border-radius: 8px;
}
.fp-color { width: 100%; height: 45px; display: block; }

/* ===== CANVAS ===== */
.canvas-wrap {
    background: var(--light);
    border-radius: var(--radius);
    padding: 0.5rem;
    text-align: center;
    width: 100%;
    overflow: hidden;
}
.canvas-wrap canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: block;
    margin: 0 auto;
}

/* ===== UPLOAD AREA ===== */
.upload-area {
    border: 2px dashed var(--gray-light);
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    background: var(--light);
}
.upload-area:active { border-color: var(--accent); }
.upload-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.upload-text { font-weight: 500; font-size: 0.9rem; margin-bottom: 0.25rem; }
.upload-hint { font-size: 0.75rem; color: var(--gray); }

/* ===== SIZE ===== */
.size-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.size-pill {
    padding: 0.55rem 0.85rem;
    border: 1.5px solid var(--gray-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8rem;
    background: var(--white);
    min-height: 38px;
    display: inline-flex;
    align-items: center;
}
.size-pill.active { border-color: var(--secondary); background: var(--secondary); color: var(--white); }

/* ===== BACKGROUND SELECTOR ===== */
.bg-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}
.bg-thumb {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
}
.bg-thumb.active { border-color: var(--secondary); }

/* ===== FRAME PROFILE GRID ===== */
.frame-profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-height: 260px;
    overflow-y: auto;
    padding: 0.25rem;
    -webkit-overflow-scrolling: touch;
}
.frame-profile-item {
    cursor: pointer;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--white);
    transition: var(--transition);
}
.frame-profile-item.active { border-color: var(--secondary); box-shadow: 0 0 0 2px rgba(139,115,85,0.2); }
.frame-profile-item img { width: 100%; height: 45px; object-fit: cover; display: block; }
.frame-profile-item > div { width: 100%; height: 45px; }
.frame-profile-name {
    display: block;
    padding: 0.3rem 0.4rem;
    font-size: 0.65rem;
    text-align: center;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== PRICE BOX ===== */
.price-box {
    background: var(--light);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1rem 0;
    border: 1.5px solid var(--gray-light);
}
.price-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-light);
    font-size: 0.85rem;
}
.price-row:last-child {
    border: none;
    padding-top: 0.85rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--secondary);
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--gray-light);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 16px; /* iOS zoom fix */
    background: var(--white);
    -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--secondary);
}
.form-textarea { min-height: 90px; resize: vertical; }

/* ===== AUTH ===== */
.auth-container { max-width: 440px; margin: 1rem auto; padding: 0 1rem; }
.auth-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.auth-title { text-align: center; margin-bottom: 1.5rem; }

/* ===== CART ===== */
.cart-table {
    width: 100%;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.cart-table table { width: 100%; border-collapse: collapse; min-width: 600px; }
.cart-table th {
    background: var(--primary);
    color: var(--white);
    padding: 0.75rem;
    text-align: left;
    font-size: 0.8rem;
}
.cart-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--gray-light);
    font-size: 0.85rem;
}
.cart-table img { width: 60px; height: 45px; object-fit: cover; border-radius: var(--radius-sm); }
.cart-qty {
    width: 55px;
    padding: 0.4rem;
    border: 1.5px solid var(--gray-light);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 14px;
}
.cart-summary {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 1rem;
    max-width: 100%;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--gray-light);
    font-weight: 500;
    font-size: 0.85rem;
    min-width: 40px;
    text-align: center;
}
.pagination .active { background: var(--secondary); color: var(--white); border-color: var(--secondary); }

/* ===== STEPS ===== */
.steps {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    text-align: center;
    padding: 1rem 0;
}
.step-number {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    color: var(--white);
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
}

/* ===== FOOTER ===== */
.site-footer {
    background: var(--primary);
    color: #ccc;
    padding: 2rem 0 1rem;
    margin-top: 2rem;
}
.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.footer-col h4 {
    color: var(--white);
    margin-bottom: 0.75rem;
    font-size: 1rem;
}
.footer-col p, .footer-col li { font-size: 0.85rem; line-height: 1.7; }
.footer-col ul { list-style: none; }
.footer-col ul a { color: #aaa; }
.footer-bottom {
    border-top: 1px solid #333;
    padding-top: 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: #777;
}

/* ===== TABLE ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table th { background: var(--light); padding: 0.75rem; text-align: left; font-weight: 600; font-size: 0.75rem; color: var(--gray); text-transform: uppercase; }
.table td { padding: 0.75rem; border-bottom: 1px solid var(--gray-light); font-size: 0.85rem; }

/* ===== BADGE ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}
.badge-success { background: #ecfdf5; color: #065f46; }
.badge-warning { background: #fffbeb; color: #92400e; }
.badge-error { background: #fef2f2; color: #991b1b; }
.badge-info { background: #eff6ff; color: #1e40af; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 560px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ======================================================= */
/* TABLET: 600px+ */
/* ======================================================= */
@media (min-width: 600px) {
    .container { padding: 0 20px; }
    h1 { font-size: 2rem; }
    h2 { font-size: 1.65rem; }

    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr 1fr; }

    .hero { padding: 3rem 0 2rem; }
    .hero h1 { font-size: 2.25rem; }
    .hero p { font-size: 1.1rem; }

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

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

    .bg-options { grid-template-columns: repeat(4, 1fr); }
    .frame-profile-grid { grid-template-columns: repeat(4, 1fr); }
    .frame-profile-item img { height: 55px; }
    .frame-profile-item > div { height: 55px; }

    .size-pill { padding: 0.6rem 1rem; font-size: 0.85rem; }
}

/* ======================================================= */
/* DESKTOP: 968px+ */
/* ======================================================= */
@media (min-width: 968px) {
    .container { padding: 0 24px; }
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }

    .site-header { padding: 1rem 0; }
    .logo img { height: 40px; }

    .mobile-toggle { display: none; }

    .main-nav {
        display: flex !important;
        position: static;
        flex-direction: row;
        padding: 0;
        box-shadow: none;
        gap: 2rem;
        background: transparent;
    }
    .main-nav a {
        padding: 0.5rem 0;
        border: none;
        width: auto;
        position: relative;
    }
    .main-nav a::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 0;
        height: 2px;
        background: var(--accent);
        transition: var(--transition);
    }
    .main-nav a:hover::after { width: 100%; }

    .header-actions { gap: 1.25rem; }
    .user-btn { padding: 0.5rem 1rem; font-size: 0.85rem; max-width: none; }
    .header-actions > a.btn { padding: 0.5rem 1.25rem; font-size: 0.85rem; }

    .hero { padding: 4rem 0 3rem; }
    .hero h1 { font-size: 3rem; }

    .section { padding: 3rem 0; }
    .section-title { font-size: 1.75rem; margin-bottom: 2rem; }
    .section-title::before { height: 30px; }

    .grid { gap: 1.5rem; }
    .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

    .product-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2.5rem;
        padding: 2rem 0;
    }
    .product-preview {
        padding: 2rem;
        position: sticky;
        top: 100px;
        align-self: start;
        margin: 0;
    }
    .product-info { padding: 2rem; margin: 0; }
    .canvas-wrap { padding: 1.5rem; }

    .upload-area { padding: 2.5rem; }
    .upload-icon { font-size: 3rem; }

    .card-img { height: 220px; }
    .frame-card .card-img { height: 220px; }

    .bg-options { grid-template-columns: repeat(5, 1fr); }
    .bg-thumb { height: 70px; }

    .frame-profile-grid { grid-template-columns: repeat(4, 1fr); max-height: 300px; }
    .frame-profile-item img { height: 60px; }
    .frame-profile-item > div { height: 60px; }
    .frame-profile-name { font-size: 0.75rem; padding: 0.4rem 0.5rem; }

    .size-pill { padding: 0.65rem 1.1rem; font-size: 0.9rem; }

    .price-box { padding: 1.5rem; }
    .price-row { padding: 0.75rem 0; font-size: 0.95rem; }
    .price-row:last-child { font-size: 1.25rem; }

    .cart-table { display: table; }
    .cart-table table { min-width: auto; }
    .cart-summary { max-width: 400px; margin-left: auto; }

    .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem; }
    .site-footer { padding: 3rem 0 1.5rem; margin-top: 4rem; }

    .steps { grid-template-columns: 1fr 1fr 1fr; gap: 2rem; padding: 2rem 0; }
    .step-number { width: 60px; height: 60px; font-size: 1.5rem; }

    .table { display: table; }
    .auth-card { padding: 2.5rem; }
    .auth-container { margin: 3rem auto; }

    .btn { padding: 0.85rem 1.75rem; font-size: 0.95rem; }
}

/* ======================================================= */
/* LARGE: 1200px+ */
/* ======================================================= */
@media (min-width: 1200px) {
    .grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}
