/* ================================================================== */
/* MONY — Custom Styles                                               */
/* Premium dark theme with glass morphism and gradient accents         */
/* ================================================================== */

/* --- Base & Variables --- */
:root {
    --bg-dark: #0a0a14;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --accent-violet: #a78bfa;
    --accent-emerald: #6ee7b7;
    --accent-rose: #fb7185;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --gradient-main: linear-gradient(135deg, var(--accent-violet), var(--accent-emerald));
    --gradient-warm: linear-gradient(135deg, #f472b6, var(--accent-violet));
    --shadow-glow: 0 0 40px rgba(167, 139, 250, 0.15), 0 0 80px rgba(110, 231, 183, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% -20%, rgba(167, 139, 250, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(110, 231, 183, 0.05), transparent);
    pointer-events: none;
    z-index: 0;
}

.bg-dark {
    background-color: var(--bg-dark);
}

.font-inter {
    font-family: 'Inter', sans-serif;
}

/* --- Gradient Text --- */
.gradient-text {
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Glass Header --- */
.glass-header {
    background: rgba(10, 10, 20, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
}

/* --- Health indicator --- */
.health-dot {
    padding: 6px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.health-dot:hover {
    transform: scale(1.2);
}

.health-dot .dot {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s, box-shadow 0.3s;
}

.health-dot .dot.ok {
    background: #34d399;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.health-dot .dot.error {
    background: var(--accent-rose);
    box-shadow: 0 0 8px rgba(251, 113, 133, 0.5);
}

/* --- Views --- */
.view {
    display: none;
    animation: fadeIn 0.35s ease;
}

.view.active {
    display: block;
}

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

/* --- Upload Zone --- */
.upload-zone {
    position: relative;
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-card);
    overflow: hidden;
}

.upload-zone:hover,
.upload-zone:focus-visible {
    border-color: var(--accent-violet);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-glow);
}

.upload-zone.has-image {
    padding: 0;
    border-style: solid;
    border-color: var(--border-hover);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Scan Icon Animation --- */
.scan-icon-wrapper {
    position: relative;
}

.scan-icon {
    color: var(--text-muted);
    transition: color 0.3s, transform 0.3s;
}

.upload-zone:hover .scan-icon {
    color: var(--accent-violet);
    transform: scale(1.05);
}

/* Pulsing ring */
.scan-icon-wrapper::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 16px;
    border: 2px solid var(--accent-violet);
    opacity: 0;
    animation: pulseRing 2.5s ease-out infinite;
}

@keyframes pulseRing {
    0% { transform: scale(0.9); opacity: 0; }
    30% { opacity: 0.3; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* --- Preview Image --- */
.preview-img {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: var(--radius-lg);
}

.clear-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border-subtle);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.clear-btn:hover {
    background: rgba(251, 113, 133, 0.8);
    transform: scale(1.1);
}

/* --- Scan Button --- */
.scan-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--gradient-main);
    color: #0a0a14;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.scan-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.scan-btn:hover:not(:disabled)::before {
    opacity: 1;
}

.scan-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(167, 139, 250, 0.3), 0 4px 15px rgba(110, 231, 183, 0.2);
}

.scan-btn:active:not(:disabled) {
    transform: translateY(0);
}

.scan-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* --- Confirm Button --- */
.confirm-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #34d399, #059669);
    color: #0a0a14;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.confirm-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.confirm-btn:hover::before {
    opacity: 1;
}

.confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(52, 211, 153, 0.3);
}

.confirm-btn:active {
    transform: translateY(0);
}

/* --- Result Card --- */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color 0.3s;
}

.result-card:hover {
    border-color: var(--border-hover);
}

/* --- Form Fields --- */
.field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.field-input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.2s, background 0.2s;
    width: 100%;
}

.field-input:focus {
    outline: none;
    border-color: var(--accent-violet);
    background: rgba(167, 139, 250, 0.06);
}

select.field-input {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5L6 8L9 5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

select.field-input option {
    background: #1a1a2e;
    color: var(--text-primary);
}

/* --- Tag Picker --- */
.tag-picker {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tag-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    user-select: none;
}

.tag-pill:hover {
    border-color: var(--accent-violet);
    color: var(--text-primary);
    background: rgba(167, 139, 250, 0.08);
}

.tag-pill.active {
    background: var(--gradient-main);
    border-color: transparent;
    color: #0a0a14;
    font-weight: 700;
    box-shadow: 0 2px 12px rgba(167, 139, 250, 0.3);
}

.tag-pill .tag-count {
    font-size: 0.65rem;
    font-weight: 600;
    opacity: 0.6;
    padding: 1px 5px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    min-width: 18px;
    text-align: center;
}

.tag-pill.active .tag-count {
    background: rgba(0, 0, 0, 0.15);
    opacity: 0.8;
}

.tag-custom-row {
    display: flex;
    gap: 8px;
}

.tag-custom-row .field-input {
    flex: 1;
}

.tag-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--accent-emerald);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.tag-add-btn:hover {
    border-color: var(--accent-emerald);
    background: rgba(110, 231, 183, 0.1);
    transform: scale(1.05);
}

/* --- Item Row --- */
.item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.2s ease;
}

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

.item-row .item-name {
    flex: 1;
}

.item-row .item-price {
    width: 90px;
    text-align: right;
}

.item-row .item-delete {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.item-row .item-delete:hover {
    color: var(--accent-rose);
    border-color: rgba(251, 113, 133, 0.3);
    background: rgba(251, 113, 133, 0.1);
}

/* --- Loading Overlay --- */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 20, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.loading-overlay.hidden {
    display: none;
}

.loading-content {
    text-align: center;
}

/* --- Spinner --- */
.spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-violet);
    border-right-color: var(--accent-emerald);
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* --- Success Animation --- */
.success-icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(52, 211, 153, 0.1);
    border: 2px solid rgba(52, 211, 153, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: successPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes successPop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- Toast --- */
.toast {
    background: rgba(30, 30, 50, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    font-size: 0.85rem;
    color: var(--text-primary);
    pointer-events: auto;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 90vw;
    text-align: center;
}

.toast.error {
    border-color: rgba(251, 113, 133, 0.3);
    color: var(--accent-rose);
}

.toast.success {
    border-color: rgba(52, 211, 153, 0.3);
    color: #34d399;
}

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

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

/* --- Responsive --- */
@media (max-width: 480px) {
    .upload-zone {
        padding: 2.5rem 1rem;
    }

    .result-card {
        padding: 16px;
    }

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

/* --- Hidden utility (Tailwind fallback) --- */
.hidden {
    display: none !important;
}

/* --- Scrollbar (webkit) --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}
