/* Counter - Mobile-First Styles */
/* Follows TrySwissKnife execute page theme */

:root {
    --primary: #1a2332;
    --accent: #00a8e8;
    --accent-hover: #0096d1;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --bg-dark: #0f1419;
    --bg-main: #1a2332;
    --bg-card: #ffffff;
    --bg-light: #f7fafc;

    --text-dark: #1f2937;
    --text-medium: #6b7280;
    --text-light: #9ca3af;
    --text-white: #ffffff;

    --border: #e5e7eb;
    --border-dark: #d1d5db;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(to bottom, #f0f4f8 0%, #e2e8f0 100%);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ===== MAIN CONTENT & CONTAINER ===== */
.main-content {
    width: 100%;
    padding-bottom: 80px; /* room for fixed footer stats */
}

/* Same max-width as header-inner so cards align with logo */
.content-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ===== HEADER (matches main dashboard) ===== */
.header {
    width: 100%;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    flex-shrink: 0;
}

.header-logo-image {
    width: 85px;
    height: 85px;
    flex-shrink: 0;
    object-fit: contain;
    display: block;
}

.header-logo-text {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1a2332;
    line-height: 1.2;
    white-space: nowrap;
}

.menu-btn {
    background: none;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: 40px;
    width: 40px;
    justify-content: center;
}
.menu-btn:hover {
    border-color: #00a8e8;
    background-color: #f7fafc;
    color: #1a2332;
}



/* Header language selector */
.language-selector-header { position: relative; }

.header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #4a5568;
    font-family: inherit;
}
.header-icon-btn:hover {
    border-color: #00a8e8;
    background: #f8fafc;
    color: #1a2332;
}

.header-icon-btn svg {
    width: 20px;
    height: 20px;
}

.lang-short {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1a2332;
    letter-spacing: 0.02em;
}
.header-icon-btn:hover .lang-short { color: #00a8e8; }

.language-dropdown-header {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 140px;
    z-index: 1100;
    display: none;
    overflow: hidden;
}
.language-dropdown-header.show { display: block; }
.language-dropdown-header .lang-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
    color: #4a5568;
    transition: background 0.15s;
    font-family: inherit;
}
.language-dropdown-header .lang-option:hover { background: #f1f5f9; }
.language-dropdown-header .lang-option.active { background: rgba(0,168,232,0.08); color: #00a8e8; }
.language-dropdown-header .lang-check { font-size: 0.75rem; opacity: 0; transition: opacity 0.15s; width: 14px; }
.language-dropdown-header .lang-option.active .lang-check { opacity: 1; }

/* Mobile ≤480px */
@media (max-width: 480px) {
    .header-inner { padding: 0.5rem 1rem; }
    .header-logo-image { width: 60px; height: 60px; }
    .header-logo-text { font-size: 1.25rem; }
    .content-container { padding: 1rem; }
}



/* ===== SEO ABOUT SECTION ===== */
.about-section {
    margin-bottom: 0;
}

.about-toggle {
    width: 100%;
    background: linear-gradient(135deg, #e3f2fd 0%, #e1f5fe 100%);
    border: 1.5px solid #4fc3f7;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 14px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #01579b;
    text-align: left;
}

.about-toggle:hover {
    background: linear-gradient(135deg, #bbdefb 0%, #b3e5fc 100%);
    border-color: #00a8e8;
}

.about-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

.about-icon { font-size: 1.1rem; flex-shrink: 0; }
.about-title { flex: 1; }
.toggle-icon { font-size: 0.875rem; transition: transform 0.3s ease; flex-shrink: 0; }

.about-content {
    background: #ffffff;
    border: 1.5px solid #e3f2fd;
    border-top: none;
    padding: 28px 24px;
    animation: aboutSlideDown 0.3s ease;
}

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

.about-content h2 {
    color: #1a2332;
    font-size: 1.25rem;
    margin-bottom: 20px;
    line-height: 1.4;
    border-bottom: 2px solid #00a8e8;
    padding-bottom: 10px;
}

.about-content h3 {
    color: #1a2332;
    font-size: 1rem;
    margin-top: 20px;
    margin-bottom: 12px;
    font-weight: 600;
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin-bottom: 24px;
}

.about-column ul,
.about-column ol { margin: 12px 0; padding-left: 22px; }
.about-column li { margin-bottom: 8px; line-height: 1.6; color: #1f2937; }
.about-column li strong { color: #1a2332; }

.how-to-steps { counter-reset: step-counter; list-style: none; padding-left: 0; }
.how-to-steps li {
    counter-increment: step-counter;
    margin-bottom: 18px;
    padding-left: 44px;
    position: relative;
}
.how-to-steps li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0; top: 0;
    background: #00a8e8;
    color: white;
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}
.how-to-steps li strong { display: block; margin-bottom: 4px; color: #1a2332; }
.how-to-steps li p { margin: 0; line-height: 1.6; color: #6b7280; }

.features-section {
    background: #f7fafc;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.feature-item {
    background: white;
    padding: 14px;
    border-radius: 8px;
    border-left: 3px solid #00a8e8;
}
.feature-item strong { display: block; color: #1a2332; margin-bottom: 5px; font-size: 0.9rem; }
.feature-item p { margin: 0; font-size: 0.85rem; line-height: 1.5; color: #6b7280; }

.use-cases-section { margin-top: 20px; }
.use-cases-section ul { margin-top: 12px; padding-left: 22px; }
.use-cases-section li { margin-bottom: 8px; line-height: 1.6; }
.use-cases-section li strong { color: #1a2332; }

@media (max-width: 768px) {
    .about-grid { grid-template-columns: 1fr; gap: 16px; }
    .about-content { padding: 20px 16px; }
    .features-grid { grid-template-columns: 1fr; }
    .about-toggle { font-size: 0.875rem; padding: 12px 16px; }
}


.info-banner {
    background: linear-gradient(135deg, #e3f2fd 0%, #e1f5fe 100%);
    border: 1.5px solid #4fc3f7;
    border-radius: 0;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 2px 4px rgba(79, 195, 247, 0.1);
    border-left: none;
    border-right: none;
}

.info-banner + .info-banner {
    border-top: none;
}

.info-banner-tip {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-color: #6ee7b7;
}

.info-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.info-text {
    color: #01579b;
    font-size: 0.875rem;
    line-height: 1.5;
    flex: 1;
}

.info-banner-tip .info-text {
    color: #065f46;
}

.info-text strong {
    font-weight: 600;
}

.info-close {
    background: none;
    border: none;
    color: #01579b;
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 1px;
}

.info-close:hover {
    background: rgba(1, 87, 155, 0.12);
    color: #004d7a;
}

.info-banner-tip .info-close {
    color: #065f46;
}
.info-banner-tip .info-close:hover {
    background: rgba(6, 95, 70, 0.12);
    color: #064e3b;
}


.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--primary);
    color: var(--text-white);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90vw;
    text-align: center;
    pointer-events: none;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== MENU OVERLAY ===== */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.menu-content {
    position: absolute;
    /* Desktop: anchor top-right, below header */
    top: 100px;
    right: max(calc((100vw - 1200px) / 2 + 1.5rem), 1.5rem);
    transform: scale(0.9);
    transform-origin: top right;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px 24px 24px;
    width: 90%;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.25s ease, opacity 0.25s ease;
    opacity: 0;
}
.menu-overlay.active .menu-content {
    transform: scale(1);
    opacity: 1;
}

/* Mobile: centre vertically */
@media (max-width: 600px) {
    .menu-content {
        top: 50%;
        right: 50%;
        transform: translate(50%, -50%) scale(0.9);
        transform-origin: center;
        width: 92%;
        max-width: 360px;
    }
    .menu-overlay.active .menu-content {
        transform: translate(50%, -50%) scale(1);
    }
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 8px;
}
.menu-header h3 { margin: 0; color: var(--text-dark); font-size: 1.1rem; }

.menu-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.close-menu {
    background: var(--bg-light);
    border: 1px solid var(--border);
    font-size: 1.25rem;
    color: var(--text-medium);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.15s;
}
.close-menu:hover { background: #fee2e2; color: var(--danger); border-color: #fca5a5; }

.menu-action {
    width: 100%;
    background: var(--bg-light);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
    color: var(--text-dark);
    font-weight: 500;
    text-align: left;
}
.menu-action:hover {
    background: var(--bg-card);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.menu-action.danger { color: var(--danger); border-color: #fca5a5; }
.menu-action.danger:hover { background: #fef2f2; border-color: var(--danger); }

.action-icon { font-size: 1.5rem; flex-shrink: 0; }
.action-content { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.action-hint { font-size: 0.75rem; color: var(--text-light); font-weight: 400; font-style: italic; }

/* ===== CONFIRM DIALOG ===== */
.confirm-content {
    text-align: center;
    padding: 32px 24px;
}
.confirm-icon { font-size: 3rem; margin-bottom: 12px; }
.confirm-content h3 { font-size: 1.25rem; margin-bottom: 8px; color: var(--text-dark); }
.confirm-content p { color: var(--text-medium); margin-bottom: 24px; font-size: 0.9375rem; }
.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9375rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-primary { background: var(--accent); color: var(--text-white); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--bg-light); color: var(--text-dark); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: var(--text-white); }
.btn-danger:hover { background: #dc2626; }

/* ===== ADD COUNTER SECTION ===== */
.add-counter-section {
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.add-counter-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.counter-name-input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    background: var(--bg-light);
    color: var(--text-dark);
    transition: border-color 0.2s;
    outline: none;
}
.counter-name-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,168,232,0.1);
    background: var(--bg-card);
}
.counter-name-input::placeholder { color: var(--text-light); }

.add-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 12px 16px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    max-width: 400px;
    margin: 0 auto;
}
.empty-icon { font-size: 4rem; margin-bottom: 20px; opacity: 0.4; }
.empty-state h2 { color: var(--text-dark); margin-bottom: 8px; }
.empty-state p { color: var(--text-medium); }

/* ===== COUNTERS GRID ===== */
.counters-container {
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

/* ===== COUNTER CARD ===== */
.counter-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s, transform 0.1s;
}
.counter-card:hover { box-shadow: var(--shadow-lg); }

.counter-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--border);
}

.counter-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-dark);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.counter-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.counter-delete-btn:hover { color: var(--danger); background: #fef2f2; }

.counter-body {
    display: flex;
    align-items: stretch;
    min-height: 90px;
}

.counter-btn {
    flex: 0 0 72px;
    border: none;
    cursor: pointer;
    font-size: 2rem;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.counter-btn-minus {
    background: #fef2f2;
    color: var(--danger);
    border-right: 1px solid var(--border);
}
.counter-btn-minus:hover { background: #fee2e2; }
.counter-btn-minus:active { background: #fca5a5; transform: scale(0.96); }

.counter-btn-plus {
    background: #f0fdf4;
    color: var(--success);
    border-left: 1px solid var(--border);
}
.counter-btn-plus:hover { background: #dcfce7; }
.counter-btn-plus:active { background: #86efac; transform: scale(0.96); }

.counter-value-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: var(--bg-card);
    cursor: pointer;
    transition: background 0.15s;
}
.counter-value-wrap:hover { background: #f8fafc; }

.counter-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    transition: transform 0.1s;
}
.counter-value.bump { transform: scale(1.2); }
.counter-value.negative { color: var(--danger); }

.counter-value-hint {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 4px;
    font-style: italic;
}

/* Last updated timestamp row */
.counter-card-footer {
    padding: 6px 14px 9px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 5px;
}

.counter-updated-label {
    font-size: 0.68rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.counter-updated-value {
    font-size: 0.72rem;
    color: var(--text-medium);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== FOOTER STATS ===== */
.footer-stats {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 50;
}

.stat-item { text-align: center; }
.stat-value { font-size: 1.25rem; font-weight: 700; color: var(--accent); }
.stat-value-sm { font-size: 1rem; font-weight: 700; color: var(--accent); letter-spacing: -0.01em; }
.stat-label { font-size: 0.75rem; color: var(--text-medium); text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== RESPONSIVE ===== */
@media (min-width: 480px) {
    .counters-container { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
    .counters-container { grid-template-columns: repeat(2, 1fr); }
    .add-counter-section { padding: 20px; }
}

@media (min-width: 1024px) {
    .counters-container { grid-template-columns: repeat(3, 1fr); }
}
