/**
 * Common CSS - Shared styles across all pages
 * This file contains styles for elements used on multiple pages
 */

@import url('theme-vars.php');
@import url('theme-bridge.css');
@import url('theme.css');
@import url('theme-page-components.php');

/* ============================================
   CSS Design Tokens - iOS Dark Theme
   ============================================ */
:root {
    /* iOS Color Palette */
    --ios-bg: var(--surface-bg, #000000);
    --ios-secondary-bg: var(--surface-card, #1c1c1e);
    --ios-tertiary-bg: var(--surface-elevated, #2c2c2e);
    --ios-separator: var(--theme-separator, rgba(58, 58, 60, 0.85));
    --ios-label: var(--text-primary, #ffffff);
    --ios-secondary-label: var(--text-muted, #8e8e93);
    --ios-accent: var(--action-primary-bg, #0a84ff);
    --ios-danger: var(--color-danger, #ff3b30);
    --ios-success: var(--color-success, #32d74b);

    /* iOS Spacing Scale */
    --spacing-1: 4px;
    --spacing-2: 6px;
    --spacing-3: 8px;
    --spacing-4: 12px;
    --spacing-5: 16px;

    /* Legacy spacing tokens (for compatibility) */
    --space-1: 4px;
    --space-2: 6px;
    --space-3: 8px;
    --space-4: 12px;
    --space-5: 16px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;
    --space-9: 48px;
    --space-10: 64px;

    /* iOS Typography Sizes */
    --font-size-caption: 11px;
    --font-size-footnote: 12px;
    --font-size-body: 14px;
    --font-size-callout: 15px;
    --font-size-headline: 17px;

    /* Legacy typography tokens (for compatibility) */
    --font-display: 28px;
    --font-title: 20px;
    --font-body: 14px;
    --font-caption: 12px;

    /* Typography Line Heights */
    --line-height-display: 1.3;
    --line-height-title: 1.4;
    --line-height-body: 1.5;
    --line-height-caption: 1.6;

    /* iOS Border Radius */
    --ios-radius-small: var(--radius-sm, 10px);
    --ios-radius: var(--radius-md, 12px);
    --ios-radius-large: var(--radius-lg, 14px);
    --ios-border-width: var(--border-width-hairline, 0.5px);

    /* Legacy radius tokens (for compatibility) */
    --radius-button: 12px;
    --radius-input: 12px;
    --radius-card: 14px;
    --radius-modal: 14px;

    /* Touch Targets & Buttons */
    --touch-min: 44px;
    --button-height: 44px;
    --button-padding: 10px;

    /* Form Elements */
    --input-height: 44px;
    --input-padding: 14px;
    --label-gap: 5px;
    --field-gap: 14px;

    /* Lists & Cards */
    --list-item-min: 48px;
    --card-padding: 16px;

    /* Navigation */
    --nav-height: 56px;
    --nav-bottom-height: 60px;
    --icon-size: 24px;

    /* Modals & Sheets */
    --sheet-padding: 18px;
    --dialog-padding: 22px;
    --modal-section-gap: 20px;

    /* Icons & Media */
    --icon-sm: 16px;
    --icon-md: 24px;
    --avatar-sm: 24px;
    --avatar-md: 40px;
    --avatar-lg: 56px;

    /* Global Layout */
    --page-padding: 16px;
    --safe-area-bottom: 20px;
}

/* Responsive adjustments for smaller phones */
@media (max-width: 374px) {
    :root {
        --font-size-body: 14px;
        --font-body: 14px;
        --page-padding: 16px;
    }
}

/* Responsive adjustments for larger phones */
@media (min-width: 415px) {
    :root {
        --page-padding: 20px;
        --button-padding: 12px;
        --card-padding: 20px;
    }
}

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

html {
    background-color: var(--ios-bg);
}

/* Base Typography */
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
    background-color: var(--ios-bg);
    color: var(--ios-label);
    line-height: var(--line-height-body);
    font-size: var(--font-size-body);
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Navigation */
.navbar {
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: var(--ios-border-width) solid var(--ios-separator);
    padding: 0;
    margin-bottom: var(--space-6);
    min-height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 var(--page-padding);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--nav-height);
    position: relative;
}

/* Desktop: Limit nav container width to 700px */
@media (min-width: 769px) {
    .nav-container {
        max-width: 700px;
    }
}

/* Navigation sections: left, center, right */
.nav-left,
.nav-center,
.nav-right {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    min-height: var(--touch-min);
    z-index: 1;
}

.nav-left {
    min-width: var(--touch-min);
}

.nav-right {
    min-width: var(--touch-min);
}

.nav-center {
    flex: 1;
    justify-content: center;
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 1;
    /* Was 0 */
}

.nav-center>* {
    pointer-events: auto;
}

/* Back button */
.nav-back-btn {
    background: none;
    border: none;
    color: var(--ios-label);
    font-size: 24px;
    font-weight: 400;
    padding: var(--spacing-2);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--ios-radius);
    transition: background-color 150ms ease-out;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
    line-height: 1;
}

.nav-back-btn:hover,
.nav-back-btn:active {
    background-color: rgba(44, 44, 46, 0.5);
}

.nav-back-btn:focus {
    outline: none;
}

/* Page title */
.nav-title {
    font-size: var(--font-size-headline);
    margin: 0;
    line-height: var(--line-height-title);
    color: var(--ios-label);
    font-weight: 600;
    text-align: center;
    padding: 0 var(--spacing-5);
}

/* Right side icon button */
.nav-right-btn {
    background: none;
    border: none;
    color: var(--ios-label);
    font-size: var(--icon-md);
    padding: var(--spacing-2);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--ios-radius);
    transition: background-color 150ms ease-out;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}

.nav-right-btn:hover,
.nav-right-btn:active {
    background-color: rgba(44, 44, 46, 0.5);
}

.nav-right-btn:focus {
    outline: none;
}

.nav-right-btn svg {
    width: var(--icon-md);
    height: var(--icon-md);
    fill: currentColor;
}

/* Legacy navigation styles (for backward compatibility) */
.nav-brand {
    display: none;
}

.nav-links {
    display: none;
}

.nav-link {
    display: none;
}

/* Container */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 var(--page-padding);
}

/* Desktop: Limit container width to 700px */
@media (min-width: 769px) {
    .container {
        max-width: 700px;
    }
}

/* Buttons - iOS Style */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: var(--touch-min);
    padding: 0 var(--button-padding);
    border-radius: 999px;
    border: none;
    outline: none;
    background: rgba(44, 44, 46, 0.98);
    color: #ffffff !important;
    font-size: var(--font-size-footnote);
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: background 150ms ease-out, filter 150ms ease-out;
}

/* Ensure all text content has white color */
.btn,
.btn * {
    color: #ffffff !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--ios-accent), #4f9dff) !important;
    color: #ffffff !important;
}

.btn-primary,
.btn-primary * {
    color: #ffffff !important;
}

.btn-secondary {
    background: rgba(44, 44, 46, 0.98) !important;
    color: #ffffff !important;
}

.btn-secondary,
.btn-secondary * {
    color: #ffffff !important;
}

.btn-danger {
    background: var(--ios-danger) !important;
    color: #ffffff !important;
}

.btn-danger,
.btn-danger * {
    color: #ffffff !important;
}

.btn:active {
    background: rgba(58, 58, 60, 0.85) !important;
}

.btn-primary:active {
    filter: brightness(0.95);
}

.btn-secondary:active {
    background: rgba(58, 58, 60, 0.98) !important;
}

.btn-danger:active {
    filter: brightness(0.95);
}

.btn-small {
    padding: 2px 8px;
    font-size: var(--font-size-caption);
    min-height: 32px;
}

.btn-block {
    width: 100%;
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--label-gap);
    margin-bottom: var(--field-gap);
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

label {
    font-weight: 500;
    color: var(--ios-label);
    font-size: var(--font-size-caption);
    line-height: var(--line-height-caption);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="password"],
select,
textarea {
    padding: var(--spacing-3) var(--input-padding);
    border: var(--ios-border-width) solid var(--ios-separator);
    border-radius: var(--ios-radius);
    background: rgba(28, 28, 30, 0.96);
    color: var(--ios-label);
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
    transition: border-color 150ms ease-out;
    min-height: var(--touch-min);
    height: var(--input-height);
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--ios-accent);
}

input[readonly] {
    background: rgba(44, 44, 46, 0.5);
    cursor: not-allowed;
    opacity: 0.7;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: var(--font-size-caption);
    line-height: var(--line-height-caption);
    color: var(--ios-secondary-label);
    margin-top: calc(var(--spacing-1) * -1);
}

.form-actions {
    margin-top: var(--space-4);
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow-y: auto;
    padding: var(--page-padding);
    padding-bottom: calc(var(--page-padding) + env(safe-area-inset-bottom, var(--safe-area-bottom)));
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: rgba(28, 28, 30, 0.96);
    margin: var(--space-6) auto;
    padding: var(--dialog-padding);
    border-radius: var(--ios-radius-large);
    border: var(--ios-border-width) solid var(--ios-separator);
    max-width: 100%;
    width: 100%;
    position: relative;
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.55);
}

/* Desktop: Limit modal width to 700px */
@media (min-width: 769px) {
    .modal-content {
        max-width: 700px;
    }
}

.modal-close {
    position: absolute;
    right: var(--spacing-4);
    top: var(--spacing-4);
    font-size: 2rem;
    font-weight: bold;
    color: var(--ios-secondary-label);
    cursor: pointer;
    line-height: 1;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    z-index: 10;
    transition: color 150ms ease-out;
}

.modal-close:hover {
    color: var(--ios-label);
}

.modal h2 {
    margin-bottom: var(--space-6);
    color: var(--ios-label);
    font-size: var(--font-size-headline);
    line-height: var(--line-height-title);
    font-weight: 600;
}

/* Badges - iOS Style */
.badge,
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    height: 20px;
    border-radius: 999px;
    background: rgba(58, 58, 60, 0.9);
    font-size: var(--font-size-caption);
    color: var(--ios-secondary-label);
    font-weight: 500;
    gap: 4px;
}

.badge-pill-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--ios-success);
}

.status-verified,
.badge-active,
.badge-sent {
    background: rgba(50, 215, 75, 0.2);
    color: var(--ios-success);
}

.status-verified .badge-pill-dot,
.badge-active .badge-pill-dot,
.badge-sent .badge-pill-dot {
    background: var(--ios-success);
}

.status-unverified {
    background: rgba(255, 59, 48, 0.2);
    color: #ff453a;
}

.status-unverified .badge-pill-dot {
    background: var(--ios-danger);
}

.badge-inactive,
.badge-pending {
    background: rgba(58, 58, 60, 0.9);
    color: var(--ios-secondary-label);
}

.badge-admin {
    background: rgba(10, 132, 255, 0.2);
    color: var(--ios-accent);
}

.badge-member {
    background: rgba(58, 58, 60, 0.9);
    color: var(--ios-secondary-label);
}

.badge-banned,
.badge-failed {
    background: rgba(255, 59, 48, 0.2);
    color: #ff453a;
}

.badge-banned .badge-pill-dot,
.badge-failed .badge-pill-dot {
    background: var(--ios-danger);
}

/* Responsive - Tablet and up */
@media (min-width: 768px) {
    .form-row {
        flex-direction: row;
    }

    .form-row .form-group {
        flex: 1;
    }
}


/* Dropdown Menu */
.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: rgba(44, 44, 46, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: var(--ios-border-width) solid var(--ios-separator);
    border-radius: var(--ios-radius);
    padding: 6px;
    min-width: 180px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.nav-dropdown.active {
    display: block;
    animation: dropdownFadeIn 0.2s ease-out;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.nav-dropdown-item {
    display: block;
    padding: 10px 14px;
    color: var(--ios-label);
    text-decoration: none;
    font-size: var(--font-size-body);
    border-radius: 8px;
    transition: background-color 0.15s ease;
}

.nav-dropdown-item:hover,
.nav-dropdown-item:active {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-dropdown-item.text-danger {
    color: var(--ios-danger);
}

.nav-right-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.profile-menu-wrapper {
    position: relative;
}

.nav-switch-btn {
    min-width: auto;
    height: 34px;
    padding: 0 12px;
    font-size: var(--font-size-footnote);
    font-weight: 600;
    background: rgba(44, 44, 46, 0.98);
    border: var(--ios-border-width) solid var(--ios-separator);
}

.dev-switcher-modal-content {
    max-width: 640px;
}

.dev-switcher-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.dev-switcher-description {
    color: var(--ios-secondary-label);
    margin-bottom: var(--space-4);
}

.dev-switcher-status {
    min-height: 20px;
    font-size: var(--font-size-footnote);
    color: var(--ios-secondary-label);
    margin-top: var(--space-3);
}

.dev-switcher-status.error {
    color: var(--ios-danger);
}

.dev-switcher-list {
    margin-top: var(--space-3);
    max-height: 360px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.dev-switcher-item {
    width: 100%;
    text-align: left;
    border: var(--ios-border-width) solid var(--ios-separator);
    border-radius: var(--ios-radius);
    background: rgba(44, 44, 46, 0.98);
    color: var(--ios-label);
    padding: var(--space-4);
    cursor: pointer;
}

.dev-switcher-item:hover,
.dev-switcher-item:active {
    background: rgba(58, 58, 60, 0.98);
}

.dev-switcher-item.current {
    border-color: var(--ios-accent);
}

.dev-switcher-item-title {
    font-weight: 600;
    margin-bottom: var(--spacing-2);
}

.dev-switcher-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    font-size: var(--font-size-footnote);
    color: var(--ios-secondary-label);
}

.dev-switcher-current-tag {
    color: var(--ios-success);
    font-weight: 600;
}
