/* Rustic, Minimalist, Full-Screen Snap Scroll Stylesheet for Counter.io */

:root {
    /* Rustic Earthy Palette */
    --bg-color: #f4efe6;         /* Alabaster / Sand */
    --text-primary: #3d3a36;     /* Warm Charcoal */
    --text-secondary: #7c756e;   /* Muted Ochre-Charcoal */
    --text-muted: #a0978d;       /* Pale Brown-Grey */
    
    --card-border: rgba(61, 58, 54, 0.08);
    --card-border-hover: rgba(61, 58, 54, 0.2);
    
    /* Soft Earthy Accents */
    --accent-sage: #8f9e8b;
    --accent-clay: #c48b71;
    --accent-blue: #7d93a6;
    
    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-accent: 'Outfit', sans-serif;
    
    --shadow-sm: 0 2px 8px rgba(61, 58, 54, 0.05);
    --shadow-md: 0 8px 24px rgba(61, 58, 54, 0.08);
    --shadow-lg: 0 16px 36px rgba(61, 58, 54, 0.12);
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

html, body {
    touch-action: pan-y;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Lock scroll to snapping container */
    position: relative;
    line-height: 1.5;
}

/* Clean Header Overlay */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 76px;
    z-index: 100;
    background: rgba(244, 239, 230, 0.35);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--card-border);
    padding: 0 2.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

/* Header Stats */
.header-stats {
    display: flex;
    gap: 1.5rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: var(--font-accent);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Buttons System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
}

.btn svg {
    width: 14px;
    height: 14px;
}

.btn-icon-only {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-only svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-color);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(61, 58, 54, 0.05);
    transform: translateY(-1px);
}

.btn-danger-text:hover {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.06);
}

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

.btn-large {
    padding: 0.8rem 1.4rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

/* Full-Screen Scroll Snapping Container */
.counters-container {
    height: 100vh;
    width: 100vw;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.counters-container::-webkit-scrollbar {
    display: none; /* Hide scrollbar for immersive layout */
}

/* Empty State */
.empty-state {
    height: 100vh;
    width: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 140px 1.5rem 2rem 1.5rem;
    background-color: var(--bg-color);
    box-sizing: border-box;
}

.empty-icon {
    width: 56px;
    height: 56px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-icon svg {
    width: 100%;
    height: 100%;
}

.empty-state h2 {
    font-family: var(--font-accent);
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    max-width: 360px;
    font-size: 0.9rem;
}

#btn-empty-add {
    width: auto;
    max-width: 260px;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
}

/* Dynamic Cyclic Colors for Rustic Aesthetic */
.counter-card:nth-of-type(4n+1) { background-color: #f4efe6; } /* Sand */
.counter-card:nth-of-type(4n+2) { background-color: #e6ede4; } /* Sage */
.counter-card:nth-of-type(4n+3) { background-color: #ede4e6; } /* Clay Rose */
.counter-card:nth-of-type(4n+4) { background-color: #e3e9ed; } /* Mist Blue */

/* Full-Screen Counter Card (Slide) */
.counter-card {
    height: 100vh;
    width: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding-top: 110px; /* offset for fixed header */
    padding-bottom: 5vh;
    position: relative;
    box-sizing: border-box;
    cursor: pointer; /* Makes viewport clicking intuitive */
    user-select: none;
}

/* Card Header - Title area */
.card-header {
    width: 90%;
    max-width: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 10;
}

.title-container {
    text-align: center;
}

.counter-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0.2rem 0.6rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.title-input {
    font-family: var(--font-main);
    font-size: 1.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--text-primary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.6rem;
    text-align: center;
    width: 280px;
    outline: none;
}

/* Vertical Side Action Buttons (Delete on top, Edit below) */
.card-side-actions {
    position: absolute;
    right: 2rem;
    top: 100px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 25;
}

.btn-card-action {
    background: rgba(61, 58, 54, 0.04);
    border: 1px solid rgba(61, 58, 54, 0.08);
    color: var(--text-secondary);
    cursor: pointer;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    outline: none;
}

.btn-card-action svg {
    width: 18px;
    height: 18px;
}

.btn-card-action:hover {
    color: var(--text-primary);
    background: rgba(61, 58, 54, 0.1);
    transform: scale(1.06);
}

.btn-card-action.btn-delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

/* Giant Number Display (No Margins, massive scaling) */
.card-body {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    pointer-events: none; /* Let click pass through to the parent slide for increments */
}

.counter-display {
    font-family: var(--font-accent);
    font-size: min(32vh, 45vw); /* Giant Print */
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -3px;
    color: var(--text-primary);
    user-select: none;
    transition: transform 0.1s ease;
}

.counter-display.pop-animation {
    animation: numberPop 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes numberPop {
    0% { transform: scale(0.92); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Minimal Footer Controls */
.card-footer {
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    z-index: 10;
}

.ctrl-btn {
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    outline: none;
}

.btn-decrement, .btn-reset {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: rgba(61, 58, 54, 0.04);
    border: 1px solid rgba(61, 58, 54, 0.08);
    color: var(--text-primary);
}

.btn-decrement:hover, .btn-reset:hover {
    background: rgba(61, 58, 54, 0.08);
    border-color: rgba(61, 58, 54, 0.2);
    transform: scale(1.05);
}

.btn-decrement:active, .btn-reset:active {
    transform: scale(0.95);
}

.btn-decrement svg, .btn-reset svg {
    width: 20px;
    height: 20px;
}

.btn-increment {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-color);
}

.btn-increment:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.btn-increment:active {
    transform: scale(0.95);
}

.btn-increment svg {
    width: 26px;
    height: 26px;
}

/* Scroll Side Indicators */
.slide-indicators {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    z-index: 90;
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(61, 58, 54, 0.15);
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    padding: 0;
}

.indicator-dot:hover {
    background: rgba(61, 58, 54, 0.4);
}

.indicator-dot.active {
    background: var(--text-primary);
    transform: scale(1.3);
}

/* Scroll Hint (rustic look) */
.scroll-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: bounce 2s infinite;
    pointer-events: none;
}

.scroll-hint svg {
    width: 20px;
    height: 20px;
    opacity: 0.6;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translate(-50%, 0);
    }
    40% {
        transform: translate(-50%, -6px);
    }
    60% {
        transform: translate(-50%, -3px);
    }
}

/* List View Modal Overlay */
.list-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(61, 58, 54, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.list-modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.list-modal-content {
    background: #fbfaf7;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.list-modal-overlay.open .list-modal-content {
    transform: translateY(0);
}

.list-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 1rem;
}

.list-modal-header h2 {
    font-family: var(--font-accent);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.btn-modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-modal-close:hover {
    color: var(--text-primary);
    background: rgba(61, 58, 54, 0.08);
}

.btn-modal-close svg {
    width: 20px;
    height: 20px;
}

.list-modal-body {
    overflow-y: auto;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-right: 0.25rem;
}

.list-modal-body::-webkit-scrollbar {
    width: 4px;
}
.list-modal-body::-webkit-scrollbar-thumb {
    background: rgba(61, 58, 54, 0.15);
    border-radius: var(--radius-full);
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    background: rgba(61, 58, 54, 0.04);
    border: 1px solid rgba(61, 58, 54, 0.08);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.list-item:hover {
    background: rgba(61, 58, 54, 0.08);
    border-color: rgba(61, 58, 54, 0.15);
    transform: translateY(-1px);
}

.list-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    word-break: break-all;
}

.list-item-value {
    font-family: var(--font-accent);
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.list-empty-text {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem 0;
    font-size: 0.9rem;
}

/* Toast Messages */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    background: #fbfaf7;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-weight: 500;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: auto;
    animation: slideIn var(--transition-normal) forwards;
}

.toast-success svg {
    color: var(--accent-sage);
}

.toast-info svg {
    color: var(--accent-blue);
}

.toast.fade-out {
    animation: fadeOut var(--transition-normal) forwards;
}

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

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Media Queries for Responsive Screens */
@media (max-width: 768px) {
    .app-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        height: 64px;
        padding: 0 1rem;
        gap: 0.5rem;
    }
    
    .header-stats {
        gap: 0.75rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .stat-value {
        font-size: 0.95rem;
    }
    
    .header-actions {
        width: auto;
        gap: 0.4rem;
        display: flex;
        justify-content: flex-end;
    }

    .btn-icon-only {
        width: 36px;
        height: 36px;
    }

    .btn-icon-only svg {
        width: 16px;
        height: 16px;
    }
    
    .counter-card {
        padding-top: 80px; /* Offset for compact 64px mobile header */
        padding-bottom: 4vh;
    }

    .empty-state {
        padding-top: 100px;
    }

    .counter-title {
        font-size: 1.4rem;
    }

    .title-input {
        font-size: 1.4rem;
        width: 220px;
    }
    
    .counter-display {
        font-size: min(28vh, 48vw);
    }
    
    .card-side-actions {
        right: 0.75rem;
        top: 135px;
    }

    .btn-card-action {
        width: 38px;
        height: 38px;
    }

    .btn-card-action svg {
        width: 16px;
        height: 16px;
    }

    .card-footer {
        gap: 1rem;
        max-width: 320px;
    }

    .btn-decrement, .btn-reset {
        width: 52px;
        height: 52px;
    }

    .btn-increment {
        width: 64px;
        height: 64px;
    }
    
    .slide-indicators {
        right: 0.6rem;
    }
}
