:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-dark: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    padding: 2rem;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(56, 189, 248, 0.1) 0%, transparent 40%);
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header & Nav */
header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.ghost-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.ghost-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.cart-trigger {
    position: relative;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-trigger .count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.logo {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.logo .highlight {
    background: linear-gradient(to right, #38bdf8, #2563eb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Grid Layout */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 3rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Glass Card Style */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Form Styles */
.form-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.input-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="color"],
select,
textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

/* Gallery Styles */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 1rem;
    border: 1px solid var(--glass-border);
}

.gallery-item {
    cursor: pointer;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    aspect-ratio: 1;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item span {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.7rem;
    padding: 4px;
    text-align: center;
    backdrop-filter: blur(4px);
}

.gallery-item:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-item.selected {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

.file-input {
    padding: 0.5rem 0;
}

.primary-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 0.75rem;
    padding: 1rem;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 1rem;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
}

.secondary-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1rem;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Preview Section */
.sticky-container {
    position: sticky;
    top: 1rem;
}

h3 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.preview-wrapper {
    background: #e2e8f0;
    padding: 2rem;
    border-radius: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
    min-height: 500px;
    overflow-x: auto;
}

.previews-flex {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

/* QSL Card Rendering */
.qsl-card-render {
    width: 550px;
    height: 350px;
    background: white;
    position: relative;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    color: #000;
    overflow: hidden;
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.qsl-card-render.hidden {
    display: none;
}

.card-content.centered {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.large-callsign {
    font-size: 5rem;
    font-weight: 900;
    opacity: 0.8;
}

.photo-placeholder {
    margin-top: 20px;
    border: 2px dashed #cbd5e1;
    padding: 20px;
    color: #64748b;
    border-radius: 10px;
}

.card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.3; /* Default opacity for bg image */
}

.card-content {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.callsign-display {
    font-size: 4rem;
    font-weight: 900;
    line-height: 1;
    color: #000;
    text-transform: uppercase;
}

.logo-display {
    width: 80px;
    height: 80px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.info-table-wrapper {
    margin: 20px 0;
}

.qso-data-table {
    width: 100%;
    border-collapse: collapse;
    border: 2px solid #000;
}

.qso-data-table th {
    background: #f1f5f9;
    font-size: 0.75rem;
    padding: 8px 4px;
    border: 1px solid #000;
    font-weight: 700;
}

.qso-data-table td {
    border: 1px solid #000;
    padding: 10px 4px;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.operator-info {
    font-size: 0.9rem;
    line-height: 1.4;
}

.op-name {
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 5px;
}

.remarks-box {
    text-align: right;
    font-size: 0.9rem;
}

.radio-info {
    font-weight: 500;
    color: #475569;
    margin-bottom: 5px;
}

.misc-info {
    font-weight: 700;
    font-style: italic;
    color: #1e293b;
}

.preview-controls {
    margin-top: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.layout-indicator {
    font-weight: 700;
    color: var(--accent);
    margin-top: 0.5rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    overflow: auto;
}

.modal-content {
    margin: 5% auto;
    width: 90%;
    max-width: 600px;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-main);
}

/* Cart Specific */
.cart-items {
    margin: 2rem 0;
    max-height: 300px;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.cart-summary {
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.summary-row.total {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 1rem;
}

.divider {
    border: none;
    border-top: 1px solid var(--glass-border);
    margin: 2rem 0;
}

/* Face Selector */
.face-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}

.face-selector.hidden {
    display: none;
}

.face-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.face-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.face-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

/* Custom Elements on Card */
.qsl-card-render {
    position: relative;
    /* Ensure child absolute positioning works */
}

.custom-element {
    position: absolute;
    cursor: move;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
}

.custom-element:hover {
    border: 1px dashed rgba(0,0,0,0.2);
}

.custom-element.selected {
    border: 1px solid var(--primary);
}

.custom-element img {
    max-width: 100%;
    max-height: 100%;
    pointer-events: none;
}

.custom-element .delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--danger);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
}

.custom-element:hover .delete-btn {
    display: flex;
}

.logo-gallery-container label {
    color: var(--text-main);
    font-weight: 600;
    margin-bottom: 0.8rem;
    display: block;
}

/* Draggable Handles (Optional, but good for premium feel) */
.resizer {
    width: 8px;
    height: 8px;
    background: var(--primary);
    position: absolute;
    right: -4px;
    bottom: -4px;
    cursor: nwse-resize;
    display: none;
}

.custom-element.selected .resizer {
    display: block;
}

/* Foldable Layout Preview (Adjusting the grid) */
.previews-flex.foldable-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 10px;
}

/* Auth & Admin Extensions */
.header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-large {
    max-width: 900px;
}

.modal-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.admin-pane {
    display: none;
}

.admin-pane.active {
    display: block;
}

.hidden {
    display: none !important;
}

/* Orders Table */
.orders-table-wrapper {
    overflow-x: auto;
    background: rgba(0,0,0,0.2);
    border-radius: 1rem;
    border: 1px solid var(--glass-border);
    margin-top: 1rem;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-main);
}

.orders-table th {
    text-align: left;
    padding: 1rem;
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.orders-table td {
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
}

.orders-table tr:hover {
    background: rgba(255,255,255,0.02);
}

.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-pending { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.status-paid { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.status-shipped { background: rgba(37, 99, 235, 0.2); color: #2563eb; }

.accent {
    color: var(--accent);
    text-decoration: none;
}

.accent:hover {
    text-decoration: underline;
}
