:root {
    --bg-main: #09090b;
    --bg-card: rgba(24, 24, 27, 0.7);
    --bg-hover: rgba(39, 39, 42, 0.9);
    
    --text-main: #fafafa;
    --text-sub: #a1a1aa;
    
    --accent: #3b82f6; /* Blue accent */
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.5);
    
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    --danger: #ef4444;
    --success: #22c55e;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
}

/* === UTILS === */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
}

.text-gradient {
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* === LOADER === */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-main);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

/* === AUTH VIEW === */
#auth-view {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.auth-card h1 {
    font-size: 28px;
    margin-bottom: 10px;
}

.auth-card p {
    color: var(--text-sub);
    margin-bottom: 30px;
    font-size: 15px;
}

input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 15px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
    outline: none;
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* === MAIN APP === */
#app-view {
    display: none;
    flex-direction: column;
    height: 100vh;
}

header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title i {
    color: var(--accent);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    font-size: 16px;
    padding: 0;
}

.icon-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.search-container {
    padding: 15px 20px;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-sub);
    font-size: 18px;
}

.search-box input {
    margin-bottom: 0;
    padding-left: 45px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* === COMPACT GRID === */
.designs-grid {
    display: grid;
    /* Exactly 3 columns like the old app */
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.design-card {
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
}

.design-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.card-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    background: #111;
    overflow: hidden;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.design-card:hover .card-img {
    transform: scale(1.05);
}

.img-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 40%);
    pointer-events: none;
}

/* Overlay Buttons */
.overlay-top-right {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 2;
}

.glass-icon-btn {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.glass-icon-btn:hover {
    background: var(--accent);
    border-color: var(--accent-hover);
    transform: scale(1.1);
}

.card-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.card-title-wrap {
    cursor: pointer;
    transition: color 0.2s;
}

.card-title-wrap:hover .card-title {
    color: var(--accent);
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-subtitle {
    font-size: 11px;
    color: var(--text-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

/* Rate Display (Read-Only) */
.rate-display {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 8px;
    font-size: 12px;
    margin-top: auto;
}

.rate-display div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}
.rate-display .val {
    font-weight: 600;
    color: var(--text-main);
}
.rate-display .lbl {
    color: var(--text-sub);
}

/* Inputs for Price & RID */
.input-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
}

.input-group {
    position: relative;
}

.input-group input {
    margin-bottom: 0;
    padding: 8px 10px;
    font-size: 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
}

.input-group input:focus {
    background: rgba(0,0,0,0.2);
}

.btn-save {
    padding: 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
}

.btn-save:hover {
    background: var(--accent);
    border-color: var(--accent);
}

/* Modal Shared Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    animation: fadeUp 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.1);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

.modal-close:hover {
    background: var(--danger);
}

/* Image Modal */
#img-modal-content {
    background: transparent;
    border: none;
    box-shadow: none;
    max-width: 90vw;
    display: flex;
    justify-content: center;
}
#img-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

/* Details Modal */
.details-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}
.details-header h2 {
    font-size: 18px;
    margin-bottom: 4px;
}
.details-header p {
    color: var(--text-sub);
    font-size: 13px;
}
.details-body {
    padding: 20px;
}

.size-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.size-table th, .size-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.size-table th {
    color: var(--text-sub);
    font-weight: 500;
}
.size-table td {
    color: var(--text-main);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-sub);
    grid-column: 1 / -1;
}
.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-main);
    color: var(--bg-main);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 9999;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* === PRINT STYLES === */
#print-section {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }
    #print-section, #print-section * {
        visibility: visible;
    }
    #print-section {
        position: absolute;
        left: 0;
        top: 0;
        width: 58mm;
        margin: 0;
        padding: 0;
        display: block !important;
    }
    html, body {
        background: white;
        height: auto;
    }
}
