@tailwind base;
@tailwind components;
@tailwind utilities;

@layer components {
    .admin-input {
        @apply w-full rounded-2xl border border-[#FAD4C2] bg-[#FFF8F3] px-4 py-2 text-sm focus:border-[#C26A3D] focus:outline-none focus:ring-0 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100;
    }

    .dshop-preloader {
        @apply fixed inset-0 z-[9999] flex flex-col items-center justify-center gap-3 bg-[#fff] dark:bg-slate-900/95 px-6 py-10 text-center text-slate-900 dark:text-white;
        backdrop-filter: blur(20px);
        background: radial-gradient(circle at center, rgba(255, 255, 255, 0.95) 0%, rgba(255, 243, 235, 0.95) 40%, rgba(242, 209, 187, 0.98) 100%);
    }

    .dshop-preloader__logo {
        @apply relative h-20 w-20 rounded-[28px] border border-[#FAD4C2] bg-white shadow-2xl dark:bg-slate-900 flex items-center justify-center;
        animation: dshop-preloader-pulse 1.3s ease-in-out infinite;
    }

    .dshop-preloader__image {
        @apply h-full w-full object-contain rounded-[24px];
    }

    .dshop-preloader__fallback {
        @apply text-lg font-bold tracking-widest text-[#C26A3D];
    }

    .bg-cashier-shell {
        background-color: #fff7f2;
        background-image:
            radial-gradient(circle at 18% 18%, rgba(194, 106, 61, 0.18), transparent 45%),
            radial-gradient(circle at 82% 12%, rgba(244, 171, 140, 0.3), transparent 40%),
            radial-gradient(circle at 40% 90%, rgba(255, 214, 170, 0.25), transparent 35%);
    }

    .dark .bg-cashier-shell {
        background-color: #020617;
        background-image:
            radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.35), transparent 45%),
            radial-gradient(circle at 80% 0%, rgba(56, 189, 248, 0.25), transparent 40%),
            radial-gradient(circle at 40% 80%, rgba(236, 72, 153, 0.18), transparent 40%);
    }

    .cashier-panel {
        border: 1px solid rgba(250, 212, 194, 0.9);
        background: rgba(255, 249, 244, 0.95);
        box-shadow: 0 25px 80px rgba(194, 106, 61, 0.12);
        backdrop-filter: blur(14px);
    }

    .dark .cashier-panel {
        border-color: rgba(148, 163, 184, 0.4);
        background: rgba(2, 6, 23, 0.85);
        box-shadow: 0 25px 60px rgba(2, 6, 23, 0.8);
    }

    .cashier-chip {
        letter-spacing: 0.25em;
        color: #c26a3d;
    }

    .dark .cashier-chip {
        color: #fcd34d;
    }

    .cashier-soft {
        background: #fff0e3;
        color: #7c3e1f;
    }

    .dark .cashier-soft {
        background: rgba(15, 23, 42, 0.65);
        color: #fef3c7;
    }

    .cashier-calculator button {
        transition: all 0.2s ease;
    }

    .cashier-calculator { position: relative; z-index: 1; }

    .cashier-calculator button:hover {
        transform: translateY(-1px);
        box-shadow: 0 10px 20px rgba(194, 106, 61, 0.15);
    }

    .cashier-preset-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        gap: 0.6rem;
        align-items: stretch;
    }

    .cashier-preset-grid__full {
        grid-column: 1 / -1;
    }

    .money-pill {
        border-radius: 999px;
        border: 1px solid rgba(250, 212, 194, 0.9);
        background: #ffffff;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        padding: 0.3rem 0.85rem;
        font-size: 0.8rem;
        font-weight: 600;
        color: #c26a3d;
        letter-spacing: 0.03em;
        text-align: center;
        white-space: nowrap;
        transition: all 0.2s ease;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
        cursor: pointer;
        user-select: none;
    }

    .money-pill:hover {
        border-color: #c26a3d;
        color: #8f3c1f;
        box-shadow: 0 12px 24px rgba(194, 106, 61, 0.12);
        transform: translateY(-1px) scale(1.01);
    }

    .money-pill--accent {
        border-color: rgba(16, 185, 129, 0.25);
        background: linear-gradient(120deg, rgba(187, 247, 208, 0.9), rgba(209, 250, 229, 0.85));
        color: #047857;
    }

    .money-pill--ghost {
        border-color: rgba(248, 113, 113, 0.35);
        background: #fff1f2;
        color: #be123c;
    }

    .dark .money-pill {
        border-color: rgba(148, 163, 184, 0.3);
        background: rgba(2, 6, 23, 0.65);
        color: #fef3c7;
    }

    .dark .money-pill:hover {
        border-color: #fbbf24;
        color: #fde68a;
        box-shadow: 0 12px 18px rgba(15, 23, 42, 0.6);
    }

    .dark .money-pill--accent {
        border-color: rgba(52, 211, 153, 0.4);
        background: rgba(6, 78, 59, 0.45);
        color: #6ee7b7;
    }

    .dark .money-pill--ghost {
        border-color: rgba(248, 113, 113, 0.4);
        background: rgba(127, 29, 29, 0.45);
        color: #fecdd3;
    }

    .cashier-pill-label {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        border-radius: 999px;
        border: 1px solid rgba(250, 212, 194, 0.4);
        padding: 0.4rem 1.1rem;
        text-transform: uppercase;
        letter-spacing: 0.3em;
        font-size: 0.65rem;
        font-weight: 700;
        color: #c26a3d;
        background: rgba(250, 212, 194, 0.2);
    }

    .dark .cashier-pill-label {
        border-color: rgba(148, 163, 184, 0.4);
        color: #fde68a;
        background: rgba(148, 163, 184, 0.18);
    }

    .cashier-amount {
        position: relative;
        display: flex;
        align-items: center;
        gap: 0.85rem;
        border-radius: 36px;
        border: 1px solid rgba(250, 212, 194, 0.9);
        padding: 0.55rem 1.2rem;
        padding-right: 2.4rem; /* space for clear button */
        background: #fff;
        box-shadow: inset 0 3px 10px rgba(250, 212, 194, 0.35);
        width: 100%;
        min-height: 56px;
        z-index: 2;
        pointer-events: auto;
        cursor: text;
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }

    .cashier-amount:focus-within {
        border-color: #c26a3d;
        box-shadow: 0 0 0 3px rgba(250, 212, 194, 0.35), inset 0 3px 12px rgba(250, 212, 194, 0.45);
    }

    .cashier-amount__prefix {
        flex: none;
        min-width: 60px;
        padding: 0.45rem 0.9rem;
        border-radius: 999px;
        background: rgba(250, 212, 194, 0.25);
        font-weight: 700;
        font-size: 1rem;
        color: #c26a3d;
        text-align: center;
    }

    .cashier-amount input {
        /* Fill the container and prevent overflow */
        flex: 1 1 auto;
        min-width: 0;
        width: 100%;

        /* Override Tailwind Forms plugin defaults to keep the field clean */
        border: none !important;
        background: transparent !important;
        outline: none !important;
        box-shadow: none !important;
        -webkit-appearance: none !important;
        appearance: none !important;
        padding: 0 !important;
        margin: 0;

        /* Typography */
        font-size: 1.35rem;
        font-weight: 700;
        color: #0f172a;
        text-align: right;
        letter-spacing: 0.02em;
        font-variant-numeric: tabular-nums;
        caret-color: #C26A3D;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cashier-amount input:focus {
        outline: none !important;
        box-shadow: none !important;
    }

    .cashier-amount input::placeholder {
        color: rgba(15, 23, 42, 0.4);
        font-weight: 600;
    }

    .cashier-amount__clear {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        border-radius: 999px;
        border: 1px solid rgba(250, 212, 194, 0.6);
        width: 28px;
        height: 28px;
        line-height: 26px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #be123c;
        background: #fff1f2;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.15s ease-in-out;
        z-index: 3;
    }
    .cashier-amount__clear:hover {
        transform: translateY(-1px);
        border-color: rgba(248, 113, 113, 0.6);
        background: #ffe4e6;
    }

    .dark .cashier-amount {
        border-color: rgba(148, 163, 184, 0.4);
        background: rgba(15, 23, 42, 0.8);
        box-shadow: inset 0 3px 10px rgba(2, 6, 23, 0.55);
    }

    .dark .cashier-amount__prefix {
        color: #fde68a;
        background: rgba(148, 163, 184, 0.2);
    }

    .dark .cashier-amount input {
        color: #f8fafc;
    }

    .dark .cashier-amount input::placeholder {
        color: rgba(248, 250, 252, 0.5);
    }

    .cashier-summary {
        border-radius: 28px;
        border: 1px solid rgba(250, 212, 194, 0.65);
        background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(255, 240, 227, 0.9));
        padding: 1.5rem;
        box-shadow: inset 0 -8px 30px rgba(250, 212, 194, 0.35);
    }

    .cashier-summary__row {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .cashier-summary__label {
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.25em;
        color: rgba(124, 62, 31, 0.65);
    }

    .cashier-summary__value {
        font-size: 1rem;
        font-weight: 700;
        color: #0f172a;
    }

    .cashier-summary__row:last-of-type {
        margin-bottom: 0;
    }

    .cashier-summary__total {
        border-top: 1px dashed rgba(194, 106, 61, 0.3);
        padding-top: 0.65rem;
    }

    .cashier-summary__total .cashier-summary__label {
        color: #c26a3d;
    }

    .cashier-summary__total .cashier-summary__value {
        font-size: 1.35rem;
        color: #c26a3d;
    }

    .dark .cashier-summary {
        border-color: rgba(148, 163, 184, 0.35);
        background: linear-gradient(145deg, rgba(2, 6, 23, 0.9), rgba(15, 23, 42, 0.85));
        box-shadow: inset 0 -8px 30px rgba(2, 6, 23, 0.65);
    }

    .dark .cashier-summary__row {
        color: #fef3c7;
    }

    .dark .cashier-summary__label {
        color: rgba(248, 250, 252, 0.55);
    }

    .dark .cashier-summary__total .cashier-summary__value {
        color: #fcd34d;
    }

    .cashier-highlight {
        border-radius: 28px;
        border: 1px solid rgba(52, 211, 153, 0.35);
        background: linear-gradient(145deg, rgba(236, 253, 245, 0.95), rgba(209, 250, 229, 0.92));
        padding: 1.25rem;
        box-shadow: 0 20px 45px rgba(16, 185, 129, 0.15);
    }

    .cashier-highlight__header {
        text-transform: uppercase;
        letter-spacing: 0.25em;
        font-size: 0.65rem;
        color: #047857;
    }

    .cashier-highlight__value {
        font-size: 1.4rem;
        font-weight: 700;
        color: #059669;
    }

    .cashier-highlight__meta {
        font-size: 0.78rem;
        color: rgba(15, 23, 42, 0.65);
    }

    .dark .cashier-highlight {
        border-color: rgba(52, 211, 153, 0.45);
        background: linear-gradient(145deg, rgba(6, 78, 59, 0.7), rgba(13, 148, 136, 0.55));
        box-shadow: 0 20px 45px rgba(6, 78, 59, 0.45);
    }

    .dark .cashier-highlight__header {
        color: #a7f3d0;
    }

    .dark .cashier-highlight__value {
        color: #bbf7d0;
    }

    .dark .cashier-highlight__meta {
        color: rgba(226, 232, 240, 0.75);
    }
}

.no-spinner::-webkit-outer-spin-button,
.no-spinner::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.no-spinner {
    -moz-appearance: textfield;
}

@layer utilities {
    .toast-leave {
        transform: translateX(8px);
        opacity: 0;
    }

    .cart-bounce {
        animation: cart-bounce 0.6s ease;
        transform-origin: center;
    }

    .dshop-preloader--hidden {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.6s ease;
    }

    .animate-fade-in {
        animation: fade-in 0.6s ease-out forwards;
        opacity: 0;
    }
}

@keyframes cart-bounce {
    0% {
        transform: scale(1);
    }

    35% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes dshop-preloader-pulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

@keyframes fade-in {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Payment Modal Keypad Styles */
.keypad-btn {
    aspect-ratio: 1;
    border-radius: 8px;
    border: 1.5px solid rgba(194, 106, 61, 0.3);
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(194, 106, 61, 0.1);
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}

.keypad-btn:hover {
    transform: translateY(-2px);
    border-color: #c26a3d;
    background: linear-gradient(145deg, #fff4ec, #ffffff);
    box-shadow: 0 4px 12px rgba(194, 106, 61, 0.2);
}

.keypad-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(194, 106, 61, 0.15);
}

.keypad-btn-danger {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(145deg, #fef2f2, #fee2e2);
    color: #dc2626;
}

.keypad-btn-danger:hover {
    border-color: #dc2626;
    background: linear-gradient(145deg, #fee2e2, #fecaca);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.keypad-btn-secondary {
    border-color: rgba(148, 163, 184, 0.4);
    background: linear-gradient(145deg, #f1f5f9, #e2e8f0);
    color: #475569;
}

.keypad-btn-secondary:hover {
    border-color: #64748b;
    background: linear-gradient(145deg, #e2e8f0, #cbd5e1);
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.2);
}

.keypad-btn-accent {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(145deg, #d1fae5, #a7f3d0);
    color: #047857;
}

.keypad-btn-accent:hover {
    border-color: #10b981;
    background: linear-gradient(145deg, #a7f3d0, #6ee7b7);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.dark .keypad-btn {
    border-color: rgba(148, 163, 184, 0.3);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.8));
    color: #f8fafc;
    box-shadow: 0 2px 8px rgba(2, 6, 23, 0.4);
}

.dark .keypad-btn:hover {
    border-color: #fbbf24;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.9));
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.2);
}

.dark .keypad-btn-danger {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(145deg, rgba(127, 29, 29, 0.6), rgba(153, 27, 27, 0.5));
    color: #fecdd3;
}

.dark .keypad-btn-danger:hover {
    border-color: #ef4444;
    background: linear-gradient(145deg, rgba(153, 27, 27, 0.7), rgba(127, 29, 29, 0.6));
}

.dark .keypad-btn-secondary {
    border-color: rgba(100, 116, 139, 0.4);
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.8), rgba(51, 65, 85, 0.7));
    color: #cbd5e1;
}

.dark .keypad-btn-secondary:hover {
    border-color: #64748b;
    background: linear-gradient(145deg, rgba(51, 65, 85, 0.9), rgba(30, 41, 59, 0.8));
}

.dark .keypad-btn-accent {
    border-color: rgba(52, 211, 153, 0.4);
    background: linear-gradient(145deg, rgba(6, 78, 59, 0.6), rgba(5, 150, 105, 0.5));
    color: #6ee7b7;
}

.dark .keypad-btn-accent:hover {
    border-color: #34d399;
    background: linear-gradient(145deg, rgba(5, 150, 105, 0.7), rgba(6, 78, 59, 0.6));
}

/* Quick Cash Buttons */
.quick-cash-btn {
    border-radius: 8px;
    border: 1.5px solid rgba(194, 106, 61, 0.3);
    background: linear-gradient(145deg, #ffffff, #fff4ec);
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #c26a3d;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(194, 106, 61, 0.1);
    user-select: none;
    text-align: center;
}

.quick-cash-btn:hover {
    transform: translateY(-2px);
    border-color: #c26a3d;
    background: linear-gradient(145deg, #fff4ec, #ffe0cc);
    box-shadow: 0 4px 12px rgba(194, 106, 61, 0.2);
    color: #8f3c1f;
}

.quick-cash-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(194, 106, 61, 0.15);
}

.dark .quick-cash-btn {
    border-color: rgba(148, 163, 184, 0.3);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.8));
    color: #fbbf24;
    box-shadow: 0 2px 6px rgba(2, 6, 23, 0.4);
}

.dark .quick-cash-btn:hover {
    border-color: #fbbf24;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.9));
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.2);
    color: #fcd34d;
}

/* Payment Modal Scroll Fix */
.payment-modal-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(194, 106, 61, 0.3) transparent;
}

.payment-modal-content::-webkit-scrollbar {
    width: 6px;
}

.payment-modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.payment-modal-content::-webkit-scrollbar-thumb {
    background-color: rgba(194, 106, 61, 0.3);
    border-radius: 3px;
}

.payment-modal-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(194, 106, 61, 0.5);
}
