/* ==========================================
   Oh My Software Theme for Mobile Web App
   Compatible with tablets and dark mode
   ========================================== */

:root {
    /* Light mode colors */
    --ios-bg-primary: #ffffff;
    --ios-bg-secondary: #f2f2f7;
    --ios-bg-tertiary: #ffffff;
    --ios-separator: rgba(60, 60, 67, 0.29);
    --ios-label-primary: #000000;
    --ios-label-secondary: rgba(60, 60, 67, 0.6);
    --ios-label-tertiary: rgba(60, 60, 67, 0.3);
    --ios-blue: #007AFF;
    --ios-navbar-bg: rgba(248, 248, 248, 0.94);
    --ios-navbar-border: rgba(0, 0, 0, 0.3);
    --ios-blur-bg: rgba(255, 255, 255, 0.72);

    /* Spacing */
    --ios-navbar-height: 44px;
    --ios-safe-area-top: env(safe-area-inset-top, 0px);
    --ios-safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --ios-navbar-margin-top: 8px;
    --ios-border-radius: 25px;

    /* Transitions */
    --ios-transition-duration: 0.35s;
    --ios-transition-timing: cubic-bezier(0.36, 0.66, 0.04, 1);
}

/* Dark mode colors */
@media (prefers-color-scheme: dark) {
    :root {
        --ios-bg-primary: #000000;
        --ios-bg-secondary: #1c1c1e;
        --ios-bg-tertiary: #2c2c2e;
        --ios-separator: rgba(84, 84, 88, 0.65);
        --ios-label-primary: #ffffff;
        --ios-label-secondary: rgba(235, 235, 245, 0.6);
        --ios-label-tertiary: rgba(235, 235, 245, 0.3);
        --ios-blue: #0A84FF;
        --ios-navbar-bg: #000000;
        --ios-navbar-border: rgba(255, 255, 255, 0.2);
        --ios-blur-bg: rgba(28, 28, 30, 0.72);
    }
}

/* Manual dark mode toggle */
[data-theme="dark"] {
    --ios-bg-primary: #000000;
    --ios-bg-secondary: #1c1c1e;
    --ios-bg-tertiary: #2c2c2e;
    --ios-separator: rgba(84, 84, 88, 0.65);
    --ios-label-primary: #ffffff;
    --ios-label-secondary: rgba(235, 235, 245, 0.6);
    --ios-label-tertiary: rgba(235, 235, 245, 0.3);
    --ios-blue: #0A84FF;
    --ios-navbar-bg: #000000;
    --ios-navbar-border: rgba(255, 255, 255, 0.2);
    --ios-blur-bg: rgba(28, 28, 30, 0.72);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
    background-color: var(--ios-bg-secondary);
    color: var(--ios-label-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App container */
.ios-app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

/* View/Page container */
.ios-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--ios-bg-secondary);
    display: flex;
    flex-direction: column;
    visibility: hidden;
    z-index: 1;
}

.ios-view.active {
    visibility: visible;
    z-index: 2;
}

/* Dynamic/Overlay views (for modals, detail pages, etc.) */
.ios-view#view-contact-detail {
    position: fixed;
    z-index: 1100;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.36, 0.66, 0.04, 1);
    pointer-events: none;
}

.ios-view#view-contact-detail.active {
    transform: translateX(0);
    pointer-events: auto;
    visibility: visible;
}

/* Navigation bar */
.ios-navbar {
    position: sticky;
    top: var(--ios-navbar-margin-top);
    left: 0;
    right: 0;
    min-height: calc(var(--ios-navbar-height) + var(--ios-safe-area-top));
    padding-top: var(--ios-safe-area-top);
    margin: var(--ios-navbar-margin-top) 12px 0 12px;
    background-color: var(--ios-navbar-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 0.5px solid var(--ios-navbar-border);
    border-radius: var(--ios-border-radius);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Prompt (optional text above navbar) */
.ios-navbar-prompt {
    font-size: 13px;
    color: var(--ios-label-secondary);
    padding: 8px 16px 4px 16px;
    text-align: center;
    line-height: 1.3;
    width: 100%;
}

/* Navbar content */
.ios-navbar-content {
    width: 100%;
    height: var(--ios-navbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    position: relative;
}

/* Navbar title */
.ios-navbar-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 17px;
    font-weight: 600;
    color: var(--ios-label-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
    pointer-events: none;
}

/* Large title (optional) */
.ios-navbar-large-title {
    font-size: 34px;
    font-weight: 700;
    padding: 0 16px 8px 16px;
    color: var(--ios-label-primary);
    letter-spacing: -0.5px;
}

/* Navbar buttons container */
.ios-navbar-left,
.ios-navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1;
}

/* Navbar button */
.ios-navbar-btn {
    background: none;
    border: none;
    color: var(--ios-blue);
    font-size: 17px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: opacity 0.2s;
    font-family: inherit;
}

.ios-navbar-btn:active {
    opacity: 0.3;
}

.ios-navbar-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Back button with chevron */
.ios-navbar-btn.back {
    padding-left: 8px;
}

.ios-navbar-btn .chevron {
    width: 13px;
    height: 21px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Content area */
.ios-content {
    flex: 1;
    min-height: 0;
    background-color: var(--ios-bg-secondary);
    padding-top: 8px;
    padding-bottom: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}


/* iOS style list */
.ios-list {
    margin: 7px 12px;
    border-radius: var(--ios-border-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.ios-list-item {
    background-color: var(--ios-bg-primary);
    border-bottom: 0.5px solid var(--ios-separator);
    padding: 11px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    transition: background-color 0.2s;
}

.ios-list-item:first-child {
    border-top-left-radius: var(--ios-border-radius);
    border-top-right-radius: var(--ios-border-radius);
}

.ios-list-item:last-child {
    border-bottom: none;
    border-bottom-left-radius: var(--ios-border-radius);
    border-bottom-right-radius: var(--ios-border-radius);
}

.ios-list-item:active {
    background-color: var(--ios-bg-tertiary);
}

.ios-list-item-label {
    font-size: 17px;
    color: var(--ios-label-primary);
}

/* Use class to align label to the right when needed */
.ios-list-item-label.align-right {
    margin-left: auto;
    padding-left: 8px;
}

.ios-list-item-value {
    font-size: 17px;
    color: var(--ios-label-secondary);
    margin-left: auto;
    padding-left: 8px;
}

.ios-list-item-chevron {
    width: 8px;
    height: 13px;
    margin-left: auto;
    opacity: 0.3;
    flex-shrink: 0;
}

/* When chevron is inside an accessory container, use normal margin */
.ios-list-item-accessory .ios-list-item-chevron {
    margin-left: 8px;
}

/* Section header */
.ios-section-header {
    font-size: 13px;
    color: var(--ios-label-secondary);
    text-transform: uppercase;
    padding: 16px 16px 6px 16px;
    margin-top: 8px;
    letter-spacing: -0.08px;
}

.ios-section-header:first-child {
    margin-top: 0;
}

/* Icon styles */
.ios-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Animations for page transitions */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-30%);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-30%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

/* Tablet support */
@media (min-width: 768px) {
    .ios-app {
        max-width: 768px;
        margin: 0 auto;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    }
}

/* Safe area support */
@supports (padding: max(0px)) {
    .ios-content {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

/* ==========================================
   Text Color Utilities
   ========================================== */

/* Primary color (blue) */
.text-primary {
    color: var(--ios-blue);
}

/* Destructive color (red) */
.text-destructive {
    color: #FF3B30;
}

/* Success color (green) */
.text-success {
    color: #34C759;
}

/* Warning color (orange) */
.text-warning {
    color: #FF9500;
}

/* Secondary label color */
.text-secondary {
    color: var(--ios-label-secondary);
}

/* Tertiary label color */
.text-tertiary {
    color: var(--ios-label-tertiary);
}

/* ==========================================
   Contact Links (Email & Phone)
   ========================================== */

.contact-link {
    display: inline;
    transition: opacity 0.2s;
}

.contact-link:active {
    opacity: 0.5;
}

/* Prevent list item hover when clicking links */
.ios-list-item:has(.contact-link:active) {
    background-color: var(--ios-bg-primary);
}

/* ==========================================
   iOS Search Bar
   ========================================== */

.ios-search-bar {
    padding: 8px 12px;
    background-color: var(--ios-bg-secondary);
    margin-bottom: 8px;
}

.ios-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background-color: rgba(142, 142, 147, 0.12);
    border-radius: 10px;
    padding: 8px 12px;
    transition: background-color 0.2s;
}

@media (prefers-color-scheme: dark) {
    .ios-search-input-wrapper {
        background-color: rgba(118, 118, 128, 0.24);
    }
}

[data-theme="dark"] .ios-search-input-wrapper {
    background-color: rgba(118, 118, 128, 0.24);
}

.ios-search-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    fill: var(--ios-label-tertiary);
    pointer-events: none;
    margin-right: 8px;
}

.ios-search-input,
.ios-search-input-wrapper input[type="search"] {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 17px;
    color: var(--ios-label-primary);
    font-family: inherit;
    width: 100%;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    z-index: 1;
}

.ios-search-input::placeholder,
.ios-search-input-wrapper input[type="search"]::placeholder {
    color: var(--ios-label-tertiary);
}

/* Remove default search input styling */
.ios-search-input::-webkit-search-cancel-button,
.ios-search-input-wrapper input[type="search"]::-webkit-search-cancel-button {
    display: none;
}

.ios-search-clear {
    background: var(--ios-label-tertiary);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    padding: 0;
    margin-left: 8px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    position: relative;
}

.ios-search-clear:active {
    opacity: 0.5;
}

.ios-search-clear::before,
.ios-search-clear::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 2px;
    background-color: white;
}

.ios-search-clear::before {
    transform: rotate(45deg);
}

.ios-search-clear::after {
    transform: rotate(-45deg);
}

/* Show clear button when input has value (will be handled via JS) */
.ios-search-clear.visible {
    display: flex;
}

/* ==========================================
   iOS Segmented Control (Tabs)
   ========================================== */

.ios-segmented-control {
    display: flex;
    background-color: var(--ios-bg-tertiary);
    border-radius: 25px;
    padding: 2px;
    margin: 12px;
}

.ios-segment {
    flex: 1;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 25px;
    font-size: 12px;
    font-weight: 400;
    color: var(--ios-label-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    margin: 0 1px;
}

.ios-segment:first-child {
    margin-left: 0;
}

.ios-segment:last-child {
    margin-right: 0;
}

.ios-segment.active {
    background-color: var(--ios-bg-primary);
    font-weight: 600;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.16);
}

.ios-segment:not(.active):active {
    opacity: 0.6;
}

/* ==========================================
   iOS Tab Content
   ========================================== */

.ios-tab-content {
    position: relative;
}

.ios-tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.ios-tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ==========================================
   iOS Form Elements
   ========================================== */

.ios-form-row {
    display: flex;
    align-items: center;
    padding: 11px 16px;
    border-bottom: 0.5px solid var(--ios-separator);
    background-color: var(--ios-bg-primary);
}

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

.ios-form-row.vertical {
    flex-direction: column;
    align-items: stretch;
}

.ios-form-label {
    font-size: 17px;
    color: var(--ios-label-primary);
    min-width: 100px;
    margin-right: 16px;
    font-weight: 500;
}

.ios-form-input,
.ios-form-textarea {
    flex: 1;
    background: none;
    border: none;
    font-size: 17px;
    color: var(--ios-label-primary);
    outline: none;
    font-family: inherit;
    text-align: right;
    min-width: 0;
    padding-right: 4px;
}

.ios-form-input::placeholder,
.ios-form-textarea::placeholder {
    color: var(--ios-label-tertiary);
}

.ios-form-row.vertical .ios-form-input,
.ios-form-row.vertical .ios-form-textarea {
    text-align: left;
    padding-right: 0;
}

.ios-form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* ==========================================
   iOS Buttons
   ========================================== */

.ios-button {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.ios-button.primary {
    background-color: var(--ios-blue);
    color: white;
}

.ios-button.primary:active {
    opacity: 0.7;
}

.ios-button.secondary {
    background-color: var(--ios-bg-tertiary);
    color: var(--ios-blue);
}

.ios-button.secondary:active {
    opacity: 0.7;
}

.ios-button.destructive {
    background-color: rgba(255, 59, 48, 0.1);
    color: #FF3B30;
}

.ios-button.destructive:active {
    opacity: 0.7;
}

/* ==========================================
   iOS Alert Box (Informational banners)
   ========================================== */

.ios-alert-banner {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    margin: 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
}

.ios-alert-banner.info {
    background-color: rgba(0, 122, 255, 0.1);
    color: var(--ios-label-primary);
}

.ios-alert-banner.success {
    background-color: rgba(52, 199, 89, 0.1);
    color: var(--ios-label-primary);
}

.ios-alert-banner.warning {
    background-color: rgba(255, 149, 0, 0.1);
    color: var(--ios-label-primary);
}

.ios-alert-banner.error {
    background-color: rgba(255, 59, 48, 0.1);
    color: var(--ios-label-primary);
}

/* Compatibility: Support .ios-alert as banner when used with info/success/warning/error */
.ios-alert.info,
.ios-alert.success,
.ios-alert.warning,
.ios-alert.error {
    display: flex !important;
    align-items: flex-start !important;
    padding: 12px 16px !important;
    margin: 12px !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    width: auto !important;
    max-width: none !important;
    animation: none !important;
    box-shadow: none !important;
}

.ios-alert.info {
    background-color: rgba(0, 122, 255, 0.1) !important;
    color: var(--ios-label-primary) !important;
}

.ios-alert.success {
    background-color: rgba(52, 199, 89, 0.1) !important;
    color: var(--ios-label-primary) !important;
}

.ios-alert.warning {
    background-color: rgba(255, 149, 0, 0.1) !important;
    color: var(--ios-label-primary) !important;
}

.ios-alert.error {
    background-color: rgba(255, 59, 48, 0.1) !important;
    color: var(--ios-label-primary) !important;
}

/* ==========================================
   iOS Radio Buttons
   ========================================== */

.ios-radio {
    display: none;
}

.ios-radio-content {
    display: flex;
    align-items: center;
    width: 100%;
}

.ios-list-item:has(.ios-radio) {
    position: relative;
}

.ios-list-item:has(.ios-radio:checked)::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--ios-blue);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: 16px;
    background-position: center;
    background-repeat: no-repeat;
}

/* ==========================================
   iOS List Item Variants
   ========================================== */

.ios-list-item-title {
    font-size: 17px;
    font-weight: 400;
    color: var(--ios-label-primary);
}

.ios-list-item-subtitle {
    font-size: 13px;
    color: var(--ios-label-secondary);
    margin-top: 2px;
}

.ios-list-item-with-image {
    display: flex;
    align-items: center;
    width: 100%;
}

.ios-list-item-image {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    margin-right: 12px;
    object-fit: contain;
}

.ios-list-item-content {
    display: flex;
    align-items: center;
    flex: 1;
}

.ios-list-item-text {
    flex: 1;
}

.ios-list-item-accessory {
    margin-left: auto;
    display: flex;
    align-items: center;
}

/* ==========================================
   Add Field Button in Section Header
   ========================================== */

.ios-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ios-btn-add-field {
    background: none;
    border: none;
    color: var(--ios-blue);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    transition: opacity 0.2s;
    font-family: inherit;
}

.ios-btn-add-field:active {
    opacity: 0.5;
}

/* iOS Footer */
.ios-footer {
    text-align: center;
    padding: 20px 16px 32px 16px;
    font-size: 12px;
    color: var(--ios-label-tertiary);
    line-height: 1.5;
}

.ios-footer a {
    color: var(--ios-label-tertiary);
    text-decoration: none;
}

.ios-footer a:active {
    opacity: 0.5;
}
