/* ── チョウセイ君 (Chousei-kun) Custom Styles ── */
/* Tailwind CDN handles utilities; this file adds custom theming & components */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+JP:wght@400;500;600;700;800&display=swap');

:root {
    --emerald-50: #ecfdf5;
    --emerald-100: #d1fae5;
    --emerald-200: #a7f3d0;
    --emerald-300: #6ee7b7;
    --emerald-400: #34d399;
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --emerald-700: #047857;
    --emerald-800: #065f46;
    --emerald-900: #064e3b;

    --bg-gradient-from: #ecfdf5;
    --bg-gradient-to: #f0fdfa;

    --status-ok: #10b981;
    --status-maybe: #f59e0b;
    --status-no: #ef4444;

    --card-bg: rgba(255, 255, 255, 0.85);
    --card-shadow: 0 10px 40px rgba(16, 185, 129, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    --card-radius: 1.25rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-from) 0%, var(--bg-gradient-to) 100%);
    min-height: 100vh;
    color: #1f2937;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
    overscroll-behavior-y: none;
    /* Prevent bounce effect on mobile */
}

/* ── Card ── */
/* ── Card ── */
.card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.1);
}

.card-header {
    padding: 1.5rem 1.5rem 0;
}

.card-content {
    padding: 1.5rem;
}

/* Base font and color updates */
:root {
    --primary-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --primary-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.39);
    --secondary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --accent-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}


/* Glassmorphism utilities */
.glass-panel {
    background: #ffffff !important;
    border-bottom: 1px solid #f1f5f9;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* Rich Hero Section */
.hero-pattern {
    background-color: #ffffff;
    background-image: radial-gradient(#10b981 0.5px, transparent 0.5px), radial-gradient(#10b981 0.5px, #ffffff 0.5px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    opacity: 0.1;
}

/* Modern Card */
.modern-card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.modern-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.1);
}

/* Gradient Buttons */
.btn-rich-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: var(--primary-shadow);
    transition: all 0.2s ease;
}

.btn-rich-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.23);
    filter: brightness(1.05);
}

.btn-rich-primary:active:not(:disabled) {
    transform: translateY(0);
}

/* Inputs */
.modern-input {
    background-color: #f8fafc;
    border: 2px solid #e2e8f0;
    transition: all 0.2s ease;
}

.modern-input:focus {
    background-color: white;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid transparent;
    outline: none;
    letter-spacing: 0.025em;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #34d399 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: #4b5563;
    border: 1.5px solid #e5e7eb;
}

.btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
}

.btn-outline {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-outline:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-lg {
    height: 3.5rem;
    padding: 0 2rem;
    font-size: 1.0625rem;
    border-radius: 9999px;
}

.btn-sm {
    height: 2.25rem;
    padding: 0 1rem;
    font-size: 0.8125rem;
    border-radius: 9999px;
    /* Pill shape for small buttons too */
}

.btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 0.625rem;
}

/* ── Input ── */
.input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    border: 1px solid transparent;
    /* No border initially */
    background: #f1f5f9;
    /* Slate 100 */
    border-radius: 1rem;
    transition: all 0.2s ease;
    outline: none;
    color: #1e293b;
    font-weight: 500;
}

.input:focus {
    background: white;
    border-color: var(--emerald-400);
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.15);
}

.input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

textarea.input {
    resize: vertical;
    min-height: 4rem;
}

/* ── Label ── */
.label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    display: block;
    margin-bottom: 0.375rem;
}

/* ── Calendar UI ── */
.calendar {
    user-select: none;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
}

.calendar-month {
    font-size: 1rem;
    font-weight: 700;
    color: var(--emerald-700);
}

.calendar-nav {
    background: none;
    border: 1.5px solid #e5e7eb;
    border-radius: 0.5rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    color: #6b7280;
    font-size: 1rem;
}

.calendar-nav:hover {
    background: var(--emerald-50);
    border-color: var(--emerald-300);
    color: var(--emerald-600);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.calendar-weekday {
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #9ca3af;
    padding: 0.375rem 0;
    text-transform: uppercase;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
    color: #374151;
    position: relative;
}

/* Only show hover effect on devices that support it (Desktop) */
@media (hover: hover) {
    .calendar-day:hover:not(.disabled):not(.empty) {
        background: var(--emerald-50);
    }
}

.calendar-day.today {
    font-weight: 700;
    color: var(--emerald-600);
}

.calendar-day.today::after {
    content: '';
    position: absolute;
    bottom: 0.15rem;
    width: 0.25rem;
    height: 0.25rem;
    border-radius: 50%;
    background: var(--emerald-500);
}

.calendar-day.selected {
    background: var(--emerald-500) !important;
    /* Force override hover/active */
    color: white;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.calendar-day.selected:hover {
    background: var(--emerald-600) !important;
}

.calendar-day.disabled {
    color: #d1d5db;
    cursor: not-allowed;
}

.calendar-day.empty {
    cursor: default;
}

.calendar-day.sunday {
    color: #ef4444;
}

.calendar-day.saturday {
    color: #3b82f6;
}

.calendar-day.selected.sunday,
.calendar-day.selected.saturday {
    color: white;
}

/* ── Status Buttons (◯△✕) ── */
.status-group {
    display: flex;
    gap: 0.25rem;
}

.status-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    border: 2px solid #e5e7eb;
    background: white;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    font-weight: 700;
}

/* ── Status Button ── */
.status-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    border: 2px solid #e2e8f0;
    background: white;
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
    font-size: 0.9375rem;
    cursor: pointer;
}

.status-btn:hover:not(:disabled) {
    transform: scale(1.1);
    border-color: #cbd5e1;
}

.status-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.status-btn.active-ok {
    background: #d1fae5;
    border-color: #059669;
    color: #047857;
    border-width: 2.5px;
    box-shadow: 0 0 0 1px #059669, 0 4px 10px rgba(16, 185, 129, 0.2);
}

.status-btn.active-maybe {
    background: #fef3c7;
    border-color: #d97706;
    color: #b45309;
    border-width: 2.5px;
    box-shadow: 0 0 0 1px #d97706, 0 4px 10px rgba(245, 158, 11, 0.2);
}

.status-btn.active-no {
    background: #ffe4e6;
    border-color: #e11d48;
    color: #be123c;
    border-width: 2.5px;
    box-shadow: 0 0 0 1px #e11d48, 0 4px 10px rgba(236, 72, 153, 0.2);
}

.status-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

/* ── Answer Matrix ── */
.matrix-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1rem;
    margin: 0 -1.5rem;
    /* Negative margin to span full width of card content */
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.matrix-table {
    width: 100%;
    min-width: 400px;
    border-collapse: separate;
    border-spacing: 0;
}

.matrix-table th,
.matrix-table td {
    padding: 0.75rem 0.5rem;
    text-align: center;
    font-size: 0.875rem;
    white-space: nowrap;
    vertical-align: middle;
}

.matrix-table thead th {
    font-weight: 600;
    color: #64748b;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 0.75rem;
}

.matrix-table thead th .date-day {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.125rem;
}

.matrix-table thead th .date-num {
    font-size: 1.125rem;
    font-weight: 800;
    color: #334155;
    line-height: 1;
}

.matrix-table tbody td:first-child {
    font-weight: 600;
    text-align: left;
    color: #374151;
    position: sticky;
    left: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 1;
}

.matrix-table tbody tr:nth-child(even) {
    background: rgba(16, 185, 129, 0.02);
}

.matrix-table .status-ok {
    color: var(--status-ok);
    font-weight: 700;
}

.matrix-table .status-maybe {
    color: var(--status-maybe);
    font-weight: 700;
}

.matrix-table .status-no {
    color: var(--status-no);
    font-weight: 700;
}

/* ── Tally Row ── */
.tally-row td {
    border-top: 2px solid #e5e7eb;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
}

.tally-best {
    background: rgba(16, 185, 129, 0.1);
    border-radius: 0.25rem;
}

/* ── Chips ── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--emerald-50);
    color: var(--emerald-700);
    border: 1px solid var(--emerald-200);
}

.chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.125rem;
    border-radius: 50%;
    color: var(--emerald-400);
    display: flex;
    transition: all 0.15s;
}

.chip-remove:hover {
    color: #ef4444;
    background: #fee2e2;
}

/* ── Organizer toggle ── */
.toggle-btn {
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1.5px solid #e5e7eb;
    background: white;
    cursor: pointer;
    transition: all 0.15s;
}

.toggle-btn.active {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

.toggle-btn:hover {
    border-color: #9ca3af;
}

/* ── Animations ── */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-fadeIn {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.slide-up,
.animate-slideUp {
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.stagger-1 {
    animation-delay: 50ms;
}

.stagger-2 {
    animation-delay: 100ms;
}

.stagger-3 {
    animation-delay: 150ms;
}

.stagger-4 {
    animation-delay: 200ms;
}

.stagger-5 {
    animation-delay: 250ms;
}

/* ── Mobile Touch Optimizations ── */
@media (hover: none) and (pointer: coarse) {

    .btn:active,
    .card:active,
    .input:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }

    .calendar-day:active {
        /* background-color: var(--emerald-100); */
        transform: scale(0.95);
    }

    /* Prevent iOS Safari auto-zoom on input focus (requires >= 16px) */
    input[type="text"],
    input[type="email"],
    input[type="url"],
    input[type="search"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="month"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease both;
}

.slide-up {
    animation: slideUp 0.4s ease both;
}

/* Staggered animations */
.stagger>*:nth-child(1) {
    animation-delay: 0s;
}

.stagger>*:nth-child(2) {
    animation-delay: 0.05s;
}

.stagger>*:nth-child(3) {
    animation-delay: 0.1s;
}

.stagger>*:nth-child(4) {
    animation-delay: 0.15s;
}

.stagger>*:nth-child(5) {
    animation-delay: 0.2s;
}

/* ── Toast / Notification ── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 100;
    animation: fadeIn 0.3s ease, fadeIn 0.3s ease 2.5s reverse forwards;
}

/* ── Responsive helpers ── */
.app-container {
    width: 100%;
    max-width: 36rem;
    margin: 0 auto;
    padding: 1rem;
}

/* ── Link styles ── */
.link {
    color: var(--emerald-600);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}

.link:hover {
    color: var(--emerald-700);
    text-decoration: underline;
}

/* ── Loading spinner ── */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Separator ── */
.divider {
    border: none;
    border-top: 1px dashed #e5e7eb;
    margin: 1rem 0;
}

/* ── Keisha-kun Link Button ── */
.btn-keisha {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-keisha:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

/* ── Google Calendar Button ── */
.btn-google {
    background: white;
    color: #374151;
    border: 1.5px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.btn-google:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btn-google img {
    width: 1.125rem;
    height: 1.125rem;
}

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 2rem 1rem;
    color: #9ca3af;
    font-size: 0.75rem;
}

.footer a {
    color: var(--emerald-500);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ── Mobile Responsive ── */

/* Touch target improvements */
@media (pointer: coarse) {
    .calendar-day {
        min-height: 2.5rem;
    }

    .calendar-nav {
        width: 2.5rem;
        height: 2.5rem;
    }

    .status-btn {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.125rem;
    }

    .chip-remove {
        padding: 0.25rem;
        font-size: 1rem;
    }
}

/* Small screens */
@media (max-width: 480px) {
    .container {
        padding: 0.625rem;
        max-width: 100%;
    }

    .card-header {
        padding: 1rem 1rem 0;
    }

    .card-content {
        padding: 1rem;
    }

    /* Smaller text */
    .btn {
        font-size: 0.875rem;
    }

    .btn-lg {
        height: 3rem;
        padding: 0 1.5rem;
        font-size: 1rem;
    }

    .input {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Calendar compact */
    .calendar-day {
        font-size: 0.75rem;
        border-radius: 0.375rem;
    }

    .calendar-weekday {
        font-size: 0.625rem;
        padding: 0.25rem 0;
    }

    /* Matrix table for mobile */
    .matrix-table {
        min-width: 280px;
    }

    .matrix-table th,
    .matrix-table td {
        padding: 0.375rem 0.25rem;
        font-size: 0.6875rem;
    }

    .matrix-table thead th .date-num {
        font-size: 0.8125rem;
    }

    .matrix-table thead th .date-day {
        font-size: 0.5625rem;
    }

    /* Candidate time rows — wrap on small screens */
    .candidate-row {
        flex-wrap: wrap;
        gap: 0.25rem !important;
    }

    /* Status buttons compact */
    .status-group {
        gap: 0.125rem;
    }

    .status-btn {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 0.9375rem;
    }

    /* Answer form candidate list */
    .space-y-2>div {
        gap: 0.25rem !important;
    }

    /* Toast position for mobile */
    .toast {
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        transform: none;
        text-align: center;
        font-size: 0.8125rem;
        padding: 0.625rem 1rem;
    }

    /* Footer tighter */
    .footer {
        padding: 1.5rem 0.5rem;
    }
}

/* Very narrow screens (iPhone SE, etc.) */
@media (max-width: 360px) {
    .container {
        padding: 0.375rem;
    }

    .card-content {
        padding: 0.75rem;
    }

    .btn-lg {
        height: 2.75rem;
        font-size: 0.9375rem;
    }

    .calendar-grid {
        gap: 0.125rem;
    }

    .calendar-day {
        font-size: 0.6875rem;
    }

    .status-btn {
        width: 2rem;
        height: 2rem;
        font-size: 0.8125rem;
        border-width: 1.5px;
    }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .toast {
        bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* ── Print styles ── */
@media print {
    body {
        background: white;
    }

    .btn,
    .footer,
    .btn-google {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}