/*
Theme Name: SubscManager
Author: Antigravity
Description: A web app style theme for managing personal subscriptions. Mobile first, B&W.
Version: 3.1.0
*/

:root {
    /* Light Mode (Default) - Pure Black & White */
    --bg-main: #FFFFFF;
    --bg-card: #F9FAFB;
    --bg-overlay: rgba(0, 0, 0, 0.5);
    
    --text-main: #000000;
    --text-muted: #6B7280;
    --text-inverse: #FFFFFF;
    
    --border-color: #E5E7EB;
    
    --accent: #000000;
    --accent-hover: #374151;
    --danger: #DC2626;

    /* Hero Card Specific */
    --hero-bg: #000000;
    --hero-text: #FFFFFF;
    --hero-muted: #9CA3AF;
    --hero-border: #333333;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Variables */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --max-width: 600px;
    --nav-height: 6rem;
}

/* Dark Mode Override */
.dark {
    --bg-main: #000000;
    --bg-card: #111111;
    --bg-overlay: rgba(255, 255, 255, 0.1);
    
    --text-main: #FFFFFF;
    --text-muted: #9CA3AF;
    --text-inverse: #000000;
    
    --border-color: #333333;
    
    --accent: #FFFFFF;
    --accent-hover: #D1D5DB;

    /* Hero Card Specific (Dark Mode) */
    --hero-bg: #222222;
    --hero-text: #FFFFFF;
    --hero-muted: #9CA3AF;
    --hero-border: #444444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* Layout */
.app-wrapper {
    max-width: var(--max-width);
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: clip;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background-color: var(--bg-main);
    z-index: 10;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.05em;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
}

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

/* Main Content area */
.content {
    flex: 1;
    padding: 1.25rem;
    padding-bottom: calc(var(--nav-height) + 6rem + env(safe-area-inset-bottom));
}

/* Tab Transitions */
.tab-pane {
    animation: simpleFade 0.8s ease-out forwards;
}
@keyframes simpleFade {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Hero Card */
.hero-card {
    background-color: var(--hero-bg);
    color: var(--hero-text);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.hero-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    opacity: 0.05;
    background-image: radial-gradient(var(--hero-text) 1px, transparent 1px);
    background-size: 8px 8px;
    pointer-events: none;
}

.hero-label, .hero-footer-label {
    font-size: 0.75rem;
    color: var(--hero-muted);
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}
.hero-footer-label {
    margin-bottom: 0;
}

.hero-value-main {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    margin-bottom: 1rem;
    line-height: 1;
    position: relative;
    z-index: 1;
}

.hero-footer {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding-top: 1rem;
    border-top: 1px solid var(--hero-border);
    position: relative;
    z-index: 1;
}

.hero-footer-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.hero-footer-item.right {
    align-items: flex-end;
}

.hero-footer-value {
    font-weight: 600;
    font-size: 1.25rem;
}

/* List Controls (3-way Switcher) */
.list-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.switcher {
    display: flex;
    position: relative;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 0.25rem;
    width: 320px;
}

.switcher-pill {
    position: absolute;
    top: 0.25rem;
    bottom: 0.25rem;
    width: calc(33.333% - 0.166rem);
    background-color: var(--accent);
    border-radius: 9999px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.switcher.is-monthly .switcher-pill {
    transform: translateX(100%);
}
.switcher.is-yearly .switcher-pill {
    transform: translateX(200%);
}

.switcher-btn {
    position: relative;
    z-index: 1;
    flex: 1;
    background: none;
    border: none;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s;
}

.switcher-btn.active {
    color: var(--text-inverse);
}

/* Subscription List */
.sub-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sub-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.sub-item-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.sub-item-name {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sub-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.sub-item-right {
    text-align: right;
    margin-left: 1rem;
    flex-shrink: 0;
}

.sub-item-price {
    font-weight: 700;
    font-size: 1.125rem;
}

.sub-item-cycle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max-width);
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    background-color: var(--bg-main);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    flex: 1;
    height: 100%;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--accent);
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 0.25rem;
}

.nav-label {
    font-size: 0.65rem;
    font-weight: 600;
}

/* FAB */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + 1.5rem + env(safe-area-inset-bottom));
    right: 1.5rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background-color: var(--accent);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    z-index: 20;
}
@media (min-width: 600px) {
    .fab {
        right: calc(50% - (var(--max-width)/2) + 1.5rem);
    }
    .hero-card {
        padding: 2rem 1.5rem;
    }
    .hero-value-main {
        font-size: 3rem;
        margin-bottom: 2rem;
    }
}
.fab svg {
    width: 24px;
    height: 24px;
}

/* Calendar View */
.calendar-container {
    padding-top: 1rem;
}
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
    margin-bottom: 1.5rem;
}
.calendar-day-header {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-bottom: 0.5rem;
}
.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    color: var(--text-main);
}
.calendar-day.empty {
    pointer-events: none;
}
.calendar-day.has-event {
    font-weight: 700;
}
.calendar-day.has-event::after {
    content: '';
    position: absolute;
    bottom: auto;
    top: calc(50% + 8px);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--accent);
}
.calendar-day.selected {
    background-color: var(--accent);
    color: var(--text-inverse);
}
.calendar-day.selected::after {
    background-color: var(--text-inverse);
}

.calendar-events h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* Graph View */
.graph-container {
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.chart-wrapper {
    width: 100%;
    max-width: 300px;
    margin-bottom: 2rem;
}

/* Smooth Modals & Overlay via CSS */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-overlay);
    backdrop-filter: blur(2px);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.slide-over {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 85%;
    max-width: 320px;
    background-color: var(--bg-main);
    z-index: 50;
    border-left: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.slide-over.is-open {
    transform: translateX(0);
}

.modal-center {
    position: fixed;
    top: 50%; left: 50%;
    width: 90%;
    max-width: 400px;
    height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    z-index: 50;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -45%);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.modal-center.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%);
}

.slide-header, .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.slide-header h2, .modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}
.modal-header {
    position: sticky;
    top: -1.5rem;
    margin-top: -1.5rem;
    padding-top: 1.5rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    background-color: var(--bg-main);
    z-index: 10;
}
.modal-header h3 { font-size: 1.125rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.form-input, .form-select {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    appearance: none;
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
}
.form-actions .btn { flex: 1; }

/* Buttons */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    text-decoration: none;
}
.btn-primary {
    background-color: var(--accent);
    color: var(--text-inverse);
}
.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-danger {
    background-color: var(--danger);
    color: white;
}

/* My Page Content */
.profile-info { margin-bottom: 2rem; }
.profile-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.profile-value {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}
.plan-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: var(--text-main);
    color: var(--bg-main);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
}
.settings-group {
    margin-bottom: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.setting-label { font-weight: 500; }
.mt-auto { margin-top: auto; }

/* iOS Style Toggle Switch */
.ios-switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.ios-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.ios-switch-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border-color);
    border-radius: 31px;
    transition: background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.ios-switch-slider::before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15), 0 3px 1px rgba(0,0,0,0.06);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.ios-switch input:checked + .ios-switch-slider {
    background-color: #000000; /* ライトモード時の真っ黒 */
}
.dark .ios-switch input:checked + .ios-switch-slider {
    background-color: #D1D5DB; /* ダークモード時の明るめグレー */
}
.ios-switch input:checked + .ios-switch-slider::before {
    transform: translateX(20px);
}
