/**
 * FORGLEMMIGEJ - Apple HIG Redesign
 * iOS Human Interface Guidelines inspired design
 */

/* === CSS VARIABLES === */
:root {
    /* iOS Semantic Colors - Backgrounds */
    --system-background: #F2F2F7;
    --secondary-background: #FFFFFF;
    --tertiary-background: #F2F2F7;
    --grouped-background: #F2F2F7;

    /* iOS Semantic Colors - Text */
    --label: #000000;
    --secondary-label: rgba(60, 60, 67, 0.85);
    --tertiary-label: rgba(60, 60, 67, 0.55);
    --placeholder-text: rgba(60, 60, 67, 0.5);

    /* iOS Semantic Colors - Fills */
    --system-fill: rgba(120, 120, 128, 0.2);
    --secondary-fill: rgba(120, 120, 128, 0.16);
    --tertiary-fill: rgba(120, 120, 128, 0.12);
    --quaternary-fill: rgba(120, 120, 128, 0.08);

    /* iOS Accent Colors */
    --system-blue: #4A55A2;
    --system-green: #34C759;
    --system-red: #FF3B30;
    --system-orange: #FF9500;
    --system-yellow: #FFCC00;
    --system-teal: #5AC8FA;
    --system-indigo: #5856D6;

    /* Separators */
    --separator: rgba(60, 60, 67, 0.29);
    --opaque-separator: #C6C6C8;

    /* Border Radius - iOS Style */
    --radius-small: 8px;
    --radius-medium: 12px;
    --radius-large: 16px;
    --radius-xlarge: 22px;
    --radius-pill: 100px;

    /* Shadows - iOS Elevation */
    --shadow-small: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-large: 0 8px 24px rgba(0, 0, 0, 0.16);
    --shadow-sheet: 0 -2px 20px rgba(0, 0, 0, 0.15);

    /* Typography - SF Pro Scale */
    --font-regular: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    --text-caption2: 11px;
    --text-caption1: 12px;
    --text-footnote: 13px;
    --text-subhead: 15px;
    --text-body: 17px;
    --text-title3: 20px;
    --text-title2: 22px;
    --text-title1: 28px;
    --text-largeTitle: 34px;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Animation */
    --spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --duration-fast: 0.15s;
    --duration-normal: 0.25s;
    --duration-slow: 0.35s;
}

/* === SKIP LINK === */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--spacing-md);
    background: var(--system-blue);
    color: #FFFFFF;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-small);
    z-index: 10000;
    font-size: var(--text-subhead);
    font-weight: var(--font-semibold);
    text-decoration: none;
}

.skip-link:focus {
    top: var(--spacing-md);
    color: #FFFFFF;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    background: var(--system-background);
    color: var(--label);
    line-height: 1.47;
    font-size: var(--text-body);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--system-blue);
    text-decoration: none;
    transition: opacity var(--duration-fast) ease;
}

a:active {
    opacity: 0.5;
}

/* === LAYOUT === */
.container {
    max-width: 560px;
    margin: 0 auto;
    padding: var(--spacing-md);
    padding-bottom: 100px;
}

/* === iOS NAVIGATION BAR === */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--system-background);
    transition: background var(--duration-fast) ease;
}

.header.scrolled {
    background: rgba(242, 242, 247, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.header h1 {
    font-size: var(--text-largeTitle);
    font-weight: var(--font-bold);
    letter-spacing: -0.5px;
    color: var(--label);
}

.header-logo {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 44px;
    width: auto;
}

/* === USER MENU === */
.user-menu {
    position: relative;
}

.user-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--secondary-fill);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) ease;
}

.user-btn:hover {
    background: var(--system-fill);
}

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

.user-btn svg {
    width: 22px;
    height: 22px;
    color: var(--system-blue);
}

.dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--secondary-background);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-large);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all var(--duration-normal) var(--spring-bounce);
    z-index: 1000;
    overflow: hidden;
}

.user-menu.open .dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown a {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 14px var(--spacing-md);
    color: var(--label);
    font-size: var(--text-body);
    transition: background var(--duration-fast) ease;
}

.dropdown a:hover {
    background: var(--quaternary-fill);
}

.dropdown a:active {
    background: var(--tertiary-fill);
}

.dropdown a svg {
    width: 20px;
    height: 20px;
    color: var(--system-blue);
}

.dropdown a.danger {
    color: var(--system-red);
}

.dropdown a.danger svg {
    color: var(--system-red);
}

.dropdown-divider {
    height: 1px;
    background: var(--separator);
    margin: var(--spacing-xs) var(--spacing-md);
}

.lang-buttons {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
}

.lang-btn {
    flex: 1;
    padding: 10px;
    font-size: var(--text-footnote);
    font-weight: var(--font-semibold);
    border: none;
    border-radius: var(--radius-small);
    background: var(--tertiary-fill);
    color: var(--secondary-label);
    cursor: pointer;
    transition: all var(--duration-fast) ease;
}

.lang-btn:hover {
    background: var(--secondary-fill);
}

.lang-btn.active {
    background: var(--system-blue);
    color: white;
}

/* Theme Toggle */
.theme-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
}

.theme-label {
    font-size: var(--text-subhead);
    color: var(--secondary-label);
}

.theme-buttons {
    display: flex;
    gap: 4px;
    background: var(--tertiary-fill);
    border-radius: var(--radius-small);
    padding: 3px;
}

.theme-btn {
    padding: 6px 10px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
    line-height: 1;
}

.theme-btn:hover {
    background: var(--secondary-fill);
}

.theme-btn.active {
    background: var(--system-blue) !important;
    color: white !important;
    box-shadow: 0 1px 3px rgba(74, 85, 162, 0.3);
}

/* === iOS SEGMENTED CONTROL === */
.filter-chips,
.segmented-control {
    display: flex;
    background: rgba(120, 120, 128, 0.16);
    border-radius: var(--radius-small);
    padding: 3px;
    margin-bottom: var(--spacing-lg);
}

.chip,
a.chip,
button.chip {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: 10px var(--spacing-md);
    font-size: var(--text-footnote);
    font-weight: var(--font-semibold);
    font-family: inherit;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--label);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
    white-space: nowrap;
    min-height: auto;
}

.chip:hover,
a.chip:hover,
button.chip:hover {
    background: rgba(120, 120, 128, 0.08);
}

.chip.active,
a.chip.active,
button.chip.active {
    background: #4A55A2;
    box-shadow: 0 2px 6px rgba(74, 85, 162, 0.4);
    color: #FFFFFF;
}

/* === VIEW TOGGLE === */
.filter-row {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    align-items: stretch;
}

.filter-row .filter-chips {
    flex: 1;
    margin-bottom: 0;
}

.view-toggle {
    display: flex;
    background: rgba(120, 120, 128, 0.16);
    border-radius: var(--radius-small);
    padding: 3px;
    flex-shrink: 0;
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    border-radius: 6px;
    background: transparent;
    color: var(--label);
    transition: all var(--duration-fast) ease;
}

.view-btn:hover {
    background: rgba(120, 120, 128, 0.08);
}

.view-btn.active {
    background: #4A55A2;
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(74, 85, 162, 0.4);
}

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

/* === iOS SEARCH BAR === */
.search-card {
    margin-bottom: var(--spacing-md);
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    color: var(--secondary-label);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: var(--text-body);
    border: none;
    border-radius: var(--radius-medium);
    background: var(--tertiary-fill);
    color: var(--label);
    transition: all var(--duration-fast) ease;
}

.search-input:focus {
    outline: none;
    background: var(--secondary-fill);
}

.search-input::placeholder {
    color: var(--placeholder-text);
}

/* === iOS CARDS === */
.card {
    background: var(--secondary-background);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-small);
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

.card-favorites {
    margin-bottom: var(--spacing-md);
}

.card-past {
    margin-top: var(--spacing-xl);
    opacity: 0.7;
}

.card-past .birthday-row {
    opacity: 0.8;
}

.section-header-muted {
    color: var(--tertiary-label);
}

.days-badge.past {
    background: var(--tertiary-fill);
    color: var(--tertiary-label);
}

/* === iOS SECTION HEADER === */
.section-header {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--text-footnote);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary-label);
    background: var(--secondary-background);
    margin: 0;
}

/* Hide old table header - using iOS list style instead */
.table-header {
    display: none;
}

/* === iOS LIST ROWS === */
.birthday-row {
    display: flex;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--secondary-background);
    border-bottom: 0.5px solid var(--separator);
    cursor: pointer;
    transition: background var(--duration-fast) ease;
    position: relative;
    overflow: hidden;
}

.birthday-row:last-child {
    border-bottom: none;
}

.birthday-row:hover {
    background: var(--quaternary-fill);
}

.birthday-row:active {
    background: var(--tertiary-fill);
}

/* Star button */
.star-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--tertiary-label);
    transition: all var(--duration-fast) var(--spring-bounce);
    flex-shrink: 0;
    margin-right: var(--spacing-sm);
}

.star-btn:hover {
    transform: scale(1.1);
}

.star-btn:active {
    transform: scale(0.9);
}

.star-btn.active {
    color: var(--system-orange);
}

/* Row content */
.row-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.name {
    font-size: var(--text-body);
    font-weight: var(--font-medium);
    color: var(--label);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.type-icon {
    font-size: var(--text-subhead);
    flex-shrink: 0;
    filter: none;
    opacity: 1;
}

.row-subtitle {
    font-size: var(--text-subhead);
    color: var(--secondary-label);
}

/* Hide old columns on mobile-first approach */
.date,
.age {
    display: none;
}

/* Days badge */
.days {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-left: var(--spacing-sm);
}

.days-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: 6px 12px;
    font-size: var(--text-subhead);
    font-weight: var(--font-semibold);
    font-variant-numeric: tabular-nums;
    background: var(--quaternary-fill);
    color: var(--secondary-label);
    border-radius: var(--radius-small);
}

.days-badge.upcoming {
    background: rgba(52, 199, 89, 0.15);
    color: #1A7431;
}

.days-badge.soon {
    background: rgba(255, 149, 0, 0.15);
    color: #C93400;
}

.days-badge.today {
    background: var(--system-blue);
    color: white;
}

/* Chevron indicator */
.row-chevron {
    width: 20px;
    height: 20px;
    color: var(--tertiary-label);
    flex-shrink: 0;
    margin-left: var(--spacing-sm);
}

/* === SWIPE ACTIONS === */
.swipe-container {
    position: relative;
    overflow: hidden;
}

.swipe-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
}

.swipe-actions-left {
    left: 0;
    transform: translateX(-100%);
}

.swipe-actions-right {
    right: 0;
    transform: translateX(100%);
}

.swipe-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    color: white;
    font-size: var(--text-subhead);
    font-weight: var(--font-medium);
}

.swipe-action-favorite {
    background: var(--system-orange);
}

.swipe-action-delete {
    background: var(--system-red);
}

/* === EMPTY STATE === */
.empty-state {
    padding: var(--spacing-xl) var(--spacing-lg);
    text-align: center;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: var(--spacing-md);
}

.empty-state h3 {
    font-size: var(--text-title3);
    font-weight: var(--font-semibold);
    color: var(--label);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    font-size: var(--text-body);
    color: var(--secondary-label);
    margin-bottom: var(--spacing-lg);
}

/* === iOS BUTTONS === */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 14px 20px;
    font-size: var(--text-body);
    font-weight: var(--font-semibold);
    border: none;
    border-radius: var(--radius-medium);
    background: var(--system-blue);
    color: white;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
    text-decoration: none;
    min-height: 50px;
}

.button:hover {
    filter: brightness(1.1);
    color: white;
}

.button:active {
    transform: scale(0.98);
    filter: brightness(0.95);
}

.button-secondary {
    background: var(--tertiary-fill);
    color: var(--system-blue);
}

.button-secondary:hover {
    background: var(--secondary-fill);
    color: var(--system-blue);
}

.button-destructive,
.delete_btn {
    background: var(--system-red);
    color: white;
    border: none;
}

.button-destructive:hover,
.delete_btn:hover {
    background: var(--system-red);
    filter: brightness(0.9);
    color: white;
}

.button-text {
    background: transparent;
    color: var(--system-blue);
    padding: 8px 12px;
    min-height: auto;
}

.button-text:hover {
    background: var(--quaternary-fill);
    color: var(--system-blue);
}

.center-button {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

/* === iOS FORMS === */
label {
    display: block;
    font-size: var(--text-footnote);
    font-weight: var(--font-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary-label);
    margin-bottom: var(--spacing-sm);
    padding-left: var(--spacing-md);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="tel"],
textarea,
select {
    width: 100%;
    padding: 14px var(--spacing-md);
    font-size: var(--text-body);
    font-family: inherit;
    border: none;
    border-radius: var(--radius-medium);
    background: var(--secondary-background);
    color: var(--label);
    margin-bottom: var(--spacing-md);
    transition: all var(--duration-fast) ease;
    box-shadow: var(--shadow-small);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.2);
}

input::placeholder,
textarea::placeholder {
    color: var(--placeholder-text);
}

/* Date picker styling */
input[type="date"] {
    position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--duration-fast) ease;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0;
}

html[data-theme="dark"] input[type="date"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white' stroke-width='1.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px 20px;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator {
        opacity: 0;
    }

    html:not([data-theme="light"]) input[type="date"] {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white' stroke-width='1.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 20px 20px;
    }
}

/* iOS Grouped Form Style */
.form-group {
    background: var(--secondary-background);
    border-radius: var(--radius-medium);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-small);
    overflow: hidden;
}

.form-group label {
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-sm);
    margin-bottom: 0;
    background: var(--secondary-background);
}

.form-group input,
.form-group select,
.form-group textarea {
    margin-bottom: 0;
    border-radius: 0;
    box-shadow: none;
}

/* === ALERTS === */
.success-message,
.alert-success {
    padding: var(--spacing-md);
    background: rgba(52, 199, 89, 0.12);
    border-radius: var(--radius-medium);
    color: #248A3D;
    margin-bottom: var(--spacing-md);
    font-size: var(--text-subhead);
    font-weight: var(--font-medium);
}

.error-message,
.alert-error {
    padding: var(--spacing-md);
    background: rgba(255, 59, 48, 0.12);
    border-radius: var(--radius-medium);
    color: var(--system-red);
    margin-bottom: var(--spacing-md);
    font-size: var(--text-subhead);
    font-weight: var(--font-medium);
}

/* === iOS BOTTOM SHEET MODAL === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--secondary-background);
    border-radius: var(--radius-large) var(--radius-large) 0 0;
    padding: var(--spacing-lg);
    padding-bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom, 20px));
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-sheet);
    animation: slideUp var(--duration-normal) var(--spring-bounce);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-handle {
    width: 36px;
    height: 5px;
    background: var(--tertiary-fill);
    border-radius: 3px;
    margin: 0 auto var(--spacing-md);
}

.modal-title {
    font-size: var(--text-title3);
    font-weight: var(--font-semibold);
    text-align: center;
    margin-bottom: var(--spacing-sm);
}

.modal-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: var(--spacing-md);
}

/* === 2FA CODE INPUT === */
.code-input-container {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.code-input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 24px;
    font-weight: var(--font-semibold);
    font-variant-numeric: tabular-nums;
    border: 2px solid var(--opaque-separator);
    border-radius: var(--radius-medium);
    background: var(--secondary-background);
    color: var(--label);
    margin-bottom: 0;
    transition: all var(--duration-fast) ease;
}

.code-input:focus {
    border-color: var(--system-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.code-input.error {
    border-color: var(--system-red);
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* === TRUST DEVICE === */
.trust-device-container {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--quaternary-fill);
    border-radius: var(--radius-medium);
    margin: var(--spacing-md) 0;
}

.trust-device-container input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin-top: 2px;
    accent-color: var(--system-blue);
}

.trust-device-container label {
    font-size: var(--text-subhead);
    text-transform: none;
    letter-spacing: normal;
    padding-left: 0;
    margin-bottom: 0;
    color: var(--label);
}

.trust-device-info {
    font-size: var(--text-footnote);
    color: var(--secondary-label);
    margin-top: var(--spacing-xs);
}

/* === PASSWORD STRENGTH === */
.strength-meter {
    height: 4px;
    background: var(--tertiary-fill);
    border-radius: 2px;
    margin-top: -var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    overflow: hidden;
}

.strength-meter-fill {
    height: 100%;
    border-radius: 2px;
    transition: all var(--duration-normal) ease;
}

.password-requirements ul {
    list-style: none;
    margin-bottom: var(--spacing-md);
    padding-left: var(--spacing-md);
}

.password-requirements li {
    font-size: var(--text-footnote);
    color: var(--secondary-label);
    padding: var(--spacing-xs) 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.password-requirements li::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tertiary-fill);
    flex-shrink: 0;
}

.password-requirements li.valid {
    color: var(--system-green);
}

.password-requirements li.valid::before {
    background: var(--system-green);
}

/* === SETTINGS === */
.settings-tabs {
    display: flex;
    background: rgba(120, 120, 128, 0.16);
    border-radius: var(--radius-small);
    padding: 3px;
    margin-bottom: var(--spacing-lg);
}

.settings-content {
    min-height: 200px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--secondary-background);
    border-radius: var(--radius-medium);
    margin-bottom: var(--spacing-sm);
    box-shadow: var(--shadow-small);
}

.setting-info h3 {
    font-size: var(--text-body);
    font-weight: var(--font-medium);
    color: var(--label);
    margin-bottom: 2px;
}

.setting-info p {
    font-size: var(--text-subhead);
    color: var(--secondary-label);
}

.setting-value {
    font-size: var(--text-body);
    color: var(--label);
    font-weight: var(--font-medium);
}

.setting-chips {
    display: flex;
    gap: 0;
    background: rgba(120, 120, 128, 0.16);
    border-radius: var(--radius-small);
    padding: 3px;
}

.setting-chips .chip,
.setting-chips button.chip {
    flex: none;
    padding: 8px 16px;
    font-size: var(--text-footnote);
    font-family: inherit;
    background: transparent;
    color: var(--label);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
    min-height: auto;
}

.setting-chips .chip.active,
.setting-chips button.chip.active {
    background: var(--system-blue) !important;
    color: #FFFFFF !important;
    font-weight: var(--font-semibold);
    box-shadow: 0 2px 6px rgba(74, 85, 162, 0.4);
}

.setting-item.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.setting-hint {
    font-size: var(--text-footnote);
    color: var(--system-orange);
    margin: -4px 0 var(--spacing-sm) var(--spacing-md);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.setting-card {
    background: var(--secondary-background);
    border-radius: var(--radius-medium);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-small);
}

.setting-card h3 {
    font-size: var(--text-subhead);
    font-weight: var(--font-medium);
    color: var(--label);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.setting-card p {
    font-size: var(--text-subhead);
    color: var(--secondary-label);
}

.setting-desc {
    font-size: var(--text-footnote);
    color: var(--secondary-label);
    margin-top: var(--spacing-sm);
}

.icon-emoji {
    font-size: var(--text-title3);
}

.section-title {
    font-size: var(--text-footnote);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary-label);
    margin: var(--spacing-lg) 0 var(--spacing-md);
    padding-left: var(--spacing-md);
}

.section-title:first-of-type {
    margin-top: 0;
}

/* === DANGER ZONE === */
.danger-zone {
    background: rgba(255, 59, 48, 0.08);
    border-radius: var(--radius-medium);
    padding: var(--spacing-lg);
    margin-top: var(--spacing-md);
}

.danger-zone h3 {
    color: var(--system-red);
    font-size: var(--text-title3);
    font-weight: var(--font-semibold);
    margin-bottom: var(--spacing-md);
}

.warning-box {
    background: rgba(255, 59, 48, 0.12);
    border-left: 4px solid var(--system-red);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    border-radius: 0 var(--radius-small) var(--radius-small) 0;
    font-size: var(--text-subhead);
    color: var(--system-red);
}

.delete-form {
    margin-top: var(--spacing-md);
}

.delete-link {
    color: var(--system-red);
    font-size: var(--text-subhead);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-sm);
}

.delete-link:hover {
    text-decoration: underline;
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: var(--text-caption1);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    border-radius: var(--radius-small);
}

.badge-success,
.badge-enabled {
    background: rgba(52, 199, 89, 0.15);
    color: #248A3D;
}

.badge-error,
.badge-disabled {
    background: var(--tertiary-fill);
    color: var(--secondary-label);
}

/* === CHECKBOX === */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--text-subhead);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--system-blue);
}

/* === iOS FAB / BOTTOM TOOLBAR === */
.fab-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--spacing-md);
    padding-bottom: calc(var(--spacing-md) + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, var(--system-background) 60%, transparent);
    z-index: 100;
    display: flex;
    justify-content: center;
}

.fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 14px 24px;
    background: #4A55A2;
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-xlarge);
    cursor: pointer;
    font-size: var(--text-body);
    font-weight: var(--font-semibold);
    box-shadow: var(--shadow-medium);
    transition: all var(--duration-fast) ease;
    text-decoration: none;
}

.fab:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-large);
    color: white;
}

.fab:active {
    transform: scale(0.98);
}

.fab svg {
    width: 20px;
    height: 20px;
}

.fab-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    display: flex;
    flex-direction: column;
    background: var(--secondary-background);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-large);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transform-origin: bottom right;
    transition: all var(--duration-normal) var(--spring-bounce);
    min-width: 220px;
}

.fab-container.open .fab-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 14px var(--spacing-lg);
    background: transparent;
    text-decoration: none;
    color: var(--label);
    white-space: nowrap;
    transition: background var(--duration-fast) ease;
    border-bottom: 0.5px solid var(--separator);
}

.fab-menu-item:last-child {
    border-bottom: none;
}

.fab-menu-item:hover {
    background: var(--quaternary-fill);
}

.fab-menu-item:active {
    background: var(--tertiary-fill);
}

.fab-menu-icon {
    font-size: var(--text-title3);
    width: 28px;
    text-align: center;
}

.fab-menu-label {
    font-size: var(--text-body);
    font-weight: var(--font-medium);
}

.fab-main {
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
}

.fab-main svg {
    width: 24px;
    height: 24px;
    transition: transform var(--duration-normal) var(--spring-bounce);
}

.fab-container.open .fab-main svg {
    transform: rotate(45deg);
}

/* === PULL TO REFRESH INDICATOR === */
.pull-indicator {
    display: flex;
    justify-content: center;
    padding: var(--spacing-md);
    color: var(--secondary-label);
}

.pull-indicator svg {
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* === TOAST NOTIFICATIONS === */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--label);
    color: var(--system-background);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-xlarge);
    font-size: var(--text-subhead);
    font-weight: var(--font-medium);
    box-shadow: var(--shadow-large);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-normal) var(--spring-bounce);
    z-index: 1001;
}

.toast.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast-action {
    color: var(--system-blue);
    margin-left: var(--spacing-md);
    cursor: pointer;
    font-weight: var(--font-semibold);
}

/* === SKELETON LOADING === */
.skeleton {
    background: linear-gradient(90deg, var(--tertiary-fill) 25%, var(--quaternary-fill) 50%, var(--tertiary-fill) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-small);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-row {
    display: flex;
    align-items: center;
    padding: var(--spacing-md);
    gap: var(--spacing-md);
}

.skeleton-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.skeleton-text {
    height: 16px;
    flex: 1;
}

.skeleton-text-short {
    height: 14px;
    width: 60%;
}

/* === HIDE FOOTER === */
footer,
.footer,
.site-footer {
    display: none !important;
}

/* === RESPONSIVE === */
@media (max-width: 640px) {
    .container {
        padding: var(--spacing-md) var(--spacing-md) 100px;
    }

    .header h1 {
        font-size: var(--text-title1);
    }

    .chip {
        padding: 8px var(--spacing-md);
        font-size: var(--text-caption1);
    }

    .birthday-row {
        padding: var(--spacing-md) var(--spacing-sm);
    }

    .star-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .name {
        font-size: var(--text-subhead);
    }

    .days-badge {
        min-width: 40px;
        padding: 5px 10px;
        font-size: var(--text-footnote);
    }

    .modal-content {
        border-radius: var(--radius-large) var(--radius-large) 0 0;
        padding: var(--spacing-md);
        padding-bottom: calc(var(--spacing-md) + env(safe-area-inset-bottom, 20px));
    }

    .code-input {
        width: 42px;
        height: 50px;
        font-size: 20px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .center-button {
        flex-direction: column;
    }

    .center-button .button {
        width: 100%;
    }

    .dropdown {
        width: calc(100vw - 32px);
        max-width: 280px;
    }

    .fab {
        padding: 14px 20px;
    }

    .fab-menu {
        right: 0;
        left: auto;
        min-width: 200px;
    }
}

@media (max-width: 375px) {
    .container {
        padding: var(--spacing-sm) var(--spacing-sm) 90px;
    }

    .header h1 {
        font-size: var(--text-title2);
    }

    .user-btn {
        width: 40px;
        height: 40px;
    }

    .chip {
        padding: 6px var(--spacing-sm);
        font-size: var(--text-caption2);
    }

    .birthday-row {
        padding: var(--spacing-sm);
    }

    .star-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
        margin-right: var(--spacing-xs);
    }

    .name {
        font-size: var(--text-footnote);
    }

    .type-icon {
        font-size: var(--text-footnote);
    }

    .row-subtitle {
        font-size: var(--text-caption1);
    }

    .days-badge {
        min-width: 36px;
        padding: 4px 8px;
        font-size: var(--text-caption1);
    }

    .code-input-container {
        gap: var(--spacing-xs);
    }

    .code-input {
        width: 36px;
        height: 44px;
        font-size: 18px;
    }

    .button {
        padding: 12px 16px;
        font-size: var(--text-subhead);
        min-height: 44px;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="number"],
    textarea,
    select {
        padding: 12px var(--spacing-md);
        font-size: var(--text-subhead);
    }
}

/* === DESKTOP ENHANCEMENTS === */
@media (min-width: 768px) {
    .container {
        padding: var(--spacing-lg);
        padding-bottom: 120px;
    }

    .header {
        padding: var(--spacing-lg) 0;
    }

    .birthday-row {
        padding: var(--spacing-md) var(--spacing-lg);
    }

    /* Show date and age on desktop */
    .date,
    .age {
        display: block;
        font-size: var(--text-subhead);
        color: var(--secondary-label);
        min-width: 100px;
    }

    .fab-container {
        justify-content: center;
        background: none;
    }

    .modal-content {
        border-radius: var(--radius-large);
        margin: auto;
    }

    .modal-overlay {
        align-items: center;
    }
}

/* === DARK MODE SUPPORT (follows system) === */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        color-scheme: dark;
        --system-blue: #4A55A2;
        --system-background: #000000;
        --secondary-background: #1C1C1E;
        --tertiary-background: #2C2C2E;
        --grouped-background: #000000;

        --label: #FFFFFF;
        --secondary-label: rgba(235, 235, 245, 0.7);
        --tertiary-label: rgba(235, 235, 245, 0.45);
        --placeholder-text: rgba(235, 235, 245, 0.45);

        --system-fill: rgba(120, 120, 128, 0.36);
        --secondary-fill: rgba(120, 120, 128, 0.32);
        --tertiary-fill: rgba(120, 120, 128, 0.24);
        --quaternary-fill: rgba(120, 120, 128, 0.18);

        --separator: rgba(84, 84, 88, 0.65);
        --opaque-separator: #38383A;
    }

    html:not([data-theme="light"]) .chip.active,
    html:not([data-theme="light"]) a.chip.active,
    html:not([data-theme="light"]) button.chip.active {
        background: #4A55A2;
        color: #FFFFFF;
    }

    html:not([data-theme="light"]) .fab {
        background: #4A55A2;
        color: #FFFFFF;
    }

    html:not([data-theme="light"]) .days-badge.upcoming {
        color: #30D158;
    }

    html:not([data-theme="light"]) .days-badge.soon {
        color: #FF9F0A;
    }

    html:not([data-theme="light"]) .header.scrolled {
        background: rgba(0, 0, 0, 0.85);
    }

    html:not([data-theme="light"]) .toast {
        background: var(--secondary-background);
        color: var(--label);
    }

    html:not([data-theme="light"]) select {
        color-scheme: dark;
    }
}

/* === MANUAL DARK MODE (data-theme attribute) === */
html[data-theme="dark"] {
    color-scheme: dark;
    --system-blue: #4A55A2;
    --system-background: #000000;
    --secondary-background: #1C1C1E;
    --tertiary-background: #2C2C2E;
    --grouped-background: #000000;

    --label: #FFFFFF;
    --secondary-label: rgba(235, 235, 245, 0.7);
    --tertiary-label: rgba(235, 235, 245, 0.45);
    --placeholder-text: rgba(235, 235, 245, 0.45);

    --system-fill: rgba(120, 120, 128, 0.36);
    --secondary-fill: rgba(120, 120, 128, 0.32);
    --tertiary-fill: rgba(120, 120, 128, 0.24);
    --quaternary-fill: rgba(120, 120, 128, 0.18);

    --separator: rgba(84, 84, 88, 0.65);
    --opaque-separator: #38383A;
}

html[data-theme="dark"] .chip.active,
html[data-theme="dark"] a.chip.active,
html[data-theme="dark"] button.chip.active {
    background: #4A55A2;
    color: #FFFFFF;
}

html[data-theme="dark"] .fab {
    background: #4A55A2;
    color: #FFFFFF;
}

html[data-theme="dark"] .days-badge.upcoming {
    color: #30D158;
}

html[data-theme="dark"] .days-badge.soon {
    color: #FF9F0A;
}

html[data-theme="dark"] .header.scrolled {
    background: rgba(0, 0, 0, 0.85);
}

html[data-theme="dark"] .toast {
    background: var(--secondary-background);
    color: var(--label);
}

html[data-theme="dark"] select {
    color-scheme: dark;
}

/* === PAGE SETTINGS (Language & Theme Toggle) === */
.page-settings {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--secondary-background);
    padding: 6px;
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-medium);
    z-index: 1000;
}

.page-settings-group {
    display: flex;
    gap: 4px;
}

.page-settings-divider {
    width: 1px;
    height: 24px;
    background: var(--separator);
}

.page-settings-btn {
    padding: 8px 12px;
    font-size: var(--text-footnote);
    font-weight: var(--font-semibold);
    border: none;
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--secondary-label);
    cursor: pointer;
    transition: all var(--duration-fast) ease;
    line-height: 1;
}

.page-settings-btn:hover {
    background: var(--tertiary-fill);
}

.page-settings-btn.active {
    background: var(--system-blue);
    color: white;
}

@media (max-width: 640px) {
    .page-settings {
        top: 12px;
        right: 12px;
        padding: 4px;
    }

    .page-settings-btn {
        padding: 6px 10px;
        font-size: var(--text-caption1);
    }

    .page-settings-divider {
        height: 20px;
    }
}

/* === PRINT STYLES === */
@media print {
    .header,
    .fab-container,
    .user-menu,
    .filter-chips {
        display: none !important;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--system-blue);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}
