/* NATIVE APP STYLING - iOS & Android Design Language */

/* Remove PWA web-app feel, add native mobile app feel */

:root {
    /* iOS/Material Design Standards */
    --nav-height: 56px;
    --tab-bar-height: 50px;
    --card-radius: 12px;
    --input-height: 44px;
    --button-height: 50px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Native colors */
    --primary-blue: #007AFF;
    --destructive-red: #FF3B30;
    --success-green: #34C759;
    --gray-1: #F2F2F7;
    --gray-2: #E5E5EA;
    --gray-3: #D1D1D6;
    --gray-4: #C7C7CC;
    /* Dark-theme text colors. This is a DARK app — these previously held leaked iOS
       light values (#000 / #3C3C43) which rendered titles black-on-dark (invisible).
       Components that genuinely sit on a light surface set their own dark color. */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    /* Shared surface tokens used by phase2-styles.css (were undefined -> broken cards) */
    --card-bg: #142238;
    --border: rgba(255, 255, 255, 0.1);
    --separator: rgba(60, 60, 67, 0.29);
}

/* .btn-secondary sits on a light grey (--gray-2) surface, so keep its text dark. */
.btn-secondary {
    color: #1a1a1a !important;
}

/* Native app body */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Helvetica Neue', sans-serif;
    font-size: 17px; /* iOS standard */
    line-height: 1.47;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Native list style (iOS Settings app style) */
.list-group {
    background: white;
    border-radius: var(--card-radius);
    margin: 16px;
    overflow: hidden;
}

.list-group-item {
    padding: 14px 16px;
    border-bottom: 0.5px solid var(--separator);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 44px;
    background: white;
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item:active {
    background: var(--gray-1);
}

/* Native buttons (large, rounded) */
button, .btn {
    min-height: var(--button-height);
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    border: none;
    background: var(--primary-blue);
    color: white;
    padding: 0 20px;
    cursor: pointer;
    transition: opacity 0.2s;
}

button:active, .btn:active {
    opacity: 0.7;
}

/* Secondary button */
.btn-secondary {
    background: var(--gray-2);
    color: var(--text-primary);
}

/* Destructive button */
.btn-danger {
    background: var(--destructive-red);
}

/* Native input fields */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea {
    min-height: var(--input-height);
    border-radius: 10px;
    border: none;
    background: var(--gray-1);
    padding: 12px 16px;
    font-size: 17px;
    width: 100%;
    box-sizing: border-box;
}

input::placeholder,
textarea::placeholder {
    color: var(--gray-4);
}

/* Native card style */
.card {
    background: white;
    border-radius: var(--card-radius);
    padding: 16px;
    margin: 12px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Native navigation bar (top) */
.mobile-header {
    height: calc(var(--nav-height) + var(--safe-top));
    padding-top: var(--safe-top);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid var(--separator);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 16px;
    padding-right: 16px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.mobile-header h1 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

/* Native tab bar (bottom) */
.bottom-nav {
    height: calc(var(--tab-bar-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--separator);
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    color: var(--gray-4);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    padding: 4px;
}

.nav-item.active {
    color: var(--primary-blue);
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
}

/* Main content area with proper padding */
.content-wrapper {
    padding-top: calc(var(--nav-height) + var(--safe-top));
    padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + 16px);
    min-height: 100vh;
    box-sizing: border-box;
}

/* Native toggle switch (iOS style) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-2);
    transition: 0.3s;
    border-radius: 31px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
    background-color: #c8a03c; /* brand gold (was success-green) */
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Native segmented control */
.segmented-control {
    display: flex;
    background: var(--gray-2);
    border-radius: 9px;
    padding: 2px;
    margin: 16px;
}

.segment {
    flex: 1;
    padding: 8px 12px;
    text-align: center;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    background: transparent;
    border: none;
    transition: background 0.2s;
}

.segment.active {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

/* Native alert/modal */
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 14px;
    padding: 20px;
    max-width: 90%;
    width: 270px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 2000;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1999;
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
}

.modal-message {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 8px;
}

.modal-actions button {
    flex: 1;
}

/* Remove web-specific elements on mobile */
@media (max-width: 768px) {
    /* Hide desktop navigation */
    .desktop-nav,
    .top-nav,
    .sidebar {
        display: none !important;
    }

    /* Remove box shadows (not native) */
    * {
        box-shadow: none !important;
    }

    /* Restore only native shadows */
    .card,
    .modal {
        box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important;
    }

    /* Remove rounded corners on full-width elements */
    body,
    .page {
        border-radius: 0 !important;
    }

    /* Native scroll behavior */
    * {
        -webkit-overflow-scrolling: touch;
    }

    /* Remove focus outlines (touch interface) */
    *:focus {
        outline: none;
    }

    /* Native tap highlights */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    button:active,
    .btn:active,
    a:active {
        opacity: 0.7;
    }
}

/* Android-specific adjustments */
.android-app {
    /* Material Design ripple effect would go here */
}

.android-app .card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.12) !important;
}

.android-app button {
    border-radius: 8px; /* Less rounded on Android */
}

/* iOS-specific adjustments */
.ios-app {
    /* iOS already styled above */
}

/* Remove PWA install prompts in native app */
.native-app .pwa-install-prompt,
.native-app .add-to-home {
    display: none !important;
}
