/**
 * Screen Time Simulator Styles
 * Apple iOS-inspired styling
 */

/* CSS Variables for theming */
.sts-container {
    --sts-bg-primary: #f2f2f7;
    --sts-bg-secondary: #ffffff;
    --sts-bg-tertiary: #e5e5ea;
    --sts-text-primary: #000000;
    --sts-text-secondary: #8e8e93;
    --sts-text-tertiary: #c7c7cc;
    --sts-separator: rgba(60, 60, 67, 0.12);
    --sts-blue: #007aff;
    --sts-green: #34c759;
    --sts-red: #ff3b30;
    --sts-orange: #ff9500;
    --sts-yellow: #ffcc00;
    --sts-purple: #af52de;
    --sts-pink: #ff2d55;
    --sts-gray: #8e8e93;
    --sts-font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --sts-border-radius: 10px;
    --sts-frame-width: 375px;
    --sts-frame-height: 812px;
}

/* Dark theme */
.sts-container.sts-theme-dark {
    --sts-bg-primary: #000000;
    --sts-bg-secondary: #1c1c1e;
    --sts-bg-tertiary: #2c2c2e;
    --sts-text-primary: #ffffff;
    --sts-text-secondary: #8e8e93;
    --sts-text-tertiary: #48484a;
    --sts-separator: rgba(84, 84, 88, 0.65);
}

/* Size variants */
.sts-container.sts-size-small {
    --sts-frame-width: 280px;
    --sts-frame-height: 606px;
}

.sts-container.sts-size-large {
    --sts-frame-width: 428px;
    --sts-frame-height: 926px;
}

/* Main container */
.sts-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    font-family: var(--sts-font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* iPhone Frame */
.sts-iphone-frame {
    width: var(--sts-frame-width);
    height: var(--sts-frame-height);
    background: var(--sts-bg-primary);
    border-radius: 47px;
    position: relative;
    box-shadow:
        0 0 0 11px #1a1a1a,
        0 0 0 13px #3a3a3a,
        0 25px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Dynamic Island / Notch */
.sts-notch {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 126px;
    height: 37px;
    background: #000000;
    border-radius: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sts-notch-inner {
    width: 10px;
    height: 10px;
    background: #1a1a2e;
    border-radius: 50%;
    position: absolute;
    right: 20px;
}

/* Status Bar */
.sts-status-bar {
    position: absolute;
    top: 12px;
    left: 0;
    right: 0;
    height: 44px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 28px;
    z-index: 50;
    color: var(--sts-text-primary);
}

.sts-status-time {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.sts-status-icons {
    display: flex;
    align-items: center;
    gap: 5px;
}

.sts-status-icons span {
    display: flex;
    align-items: center;
}

.sts-status-icons svg {
    width: auto;
    height: 12px;
}

/* Screen Content Area */
.sts-screen {
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 34px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.sts-header {
    padding: 8px 16px 8px;
    background: var(--sts-bg-primary);
    position: relative;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.sts-back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--sts-blue);
    font-size: 17px;
    padding: 0;
    cursor: pointer;
    margin-bottom: 8px;
}

.sts-back-btn svg {
    width: 12px;
    height: 20px;
    fill: var(--sts-blue);
}

.sts-back-btn:hover {
    opacity: 0.7;
}

.sts-title {
    font-size: 34px;
    font-weight: 700;
    color: var(--sts-text-primary);
    margin: 0;
    padding: 0;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.sts-header.sts-header-compact .sts-title {
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    flex: 1;
    padding-left: 60px;
}

/* Menu Wrapper */
.sts-menu-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* Hide scrollbar but keep functionality */
.sts-menu-wrapper::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

/* Menu */
.sts-menu {
    padding: 0 16px 20px;
}

/* Menu Groups - PHP version with header/footer */
.sts-menu-group-wrapper {
    margin-bottom: 35px;
}

.sts-menu-group-wrapper:first-child {
    margin-top: 10px;
}

.sts-group-header {
    font-size: 13px;
    font-weight: 400;
    color: var(--sts-text-secondary);
    text-transform: uppercase;
    letter-spacing: -0.08px;
    padding: 0 16px 8px;
    margin: 0;
}

.sts-group-footer {
    font-size: 13px;
    color: var(--sts-text-secondary);
    padding: 8px 16px 0;
    line-height: 1.4;
    margin: 0;
}

/* Menu Groups - container for items */
.sts-group-items,
.sts-menu-group {
    background: var(--sts-bg-secondary);
    border-radius: var(--sts-border-radius);
    overflow: hidden;
}

/* Menu Items */
.sts-menu-item {
    display: flex;
    align-items: center;
    padding: 11px 16px;
    min-height: 44px;
    cursor: pointer;
    transition: background-color 0.1s ease;
    position: relative;
    box-sizing: border-box;
}

.sts-menu-item:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 59px;
    right: 0;
    height: 0.5px;
    background: var(--sts-separator);
}

.sts-menu-item:active {
    background: var(--sts-bg-tertiary);
}

/* Menu Item Icon (sts-item-icon for PHP, sts-menu-icon for JS) */
.sts-item-icon,
.sts-menu-icon {
    width: 29px;
    height: 29px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    flex-shrink: 0;
    background: var(--sts-blue);
}

.sts-item-icon svg,
.sts-menu-icon svg {
    width: 17px;
    height: 17px;
    stroke: #ffffff;
    fill: none;
}

/* Icon background colors */
.sts-icon-blue { background: var(--sts-blue); }
.sts-icon-green { background: var(--sts-green); }
.sts-icon-red { background: var(--sts-red); }
.sts-icon-orange { background: var(--sts-orange); }
.sts-icon-yellow { background: var(--sts-yellow); }
.sts-icon-purple { background: var(--sts-purple); }
.sts-icon-pink { background: var(--sts-pink); }
.sts-icon-gray { background: var(--sts-gray); }
.sts-icon-teal { background: #5ac8fa; }
.sts-icon-indigo { background: #5856d6; }

/* Menu Item Content */
.sts-item-content {
    flex: 1;
    min-width: 0;
}

.sts-item-label,
.sts-menu-label {
    font-size: 17px;
    color: var(--sts-text-primary);
    line-height: 1.3;
    letter-spacing: -0.4px;
    flex: 1;
}

.sts-item-subtitle {
    font-size: 13px;
    color: var(--sts-text-secondary);
    margin-top: 2px;
    line-height: 1.3;
}

/* Menu Item Right Side */
.sts-item-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    flex-shrink: 0;
}

.sts-item-value {
    font-size: 17px;
    color: var(--sts-text-secondary);
}

.sts-item-chevron,
.sts-menu-arrow {
    width: 8px;
    height: 13px;
    color: var(--sts-text-tertiary);
    flex-shrink: 0;
    margin-left: auto;
}

.sts-item-chevron svg,
.sts-menu-arrow svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
}

/* Menu check (for selected options) */
.sts-menu-check {
    width: 16px;
    height: 16px;
    color: var(--sts-blue);
    margin-left: auto;
    flex-shrink: 0;
}

.sts-menu-check svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
}

/* Toggle Switch */
.sts-toggle,
.sts-menu-toggle {
    width: 51px;
    height: 31px;
    flex-shrink: 0;
    margin-left: auto;
}

.sts-toggle-track {
    display: block;
    width: 51px;
    height: 31px;
    background: var(--sts-bg-tertiary);
    border-radius: 31px;
    position: relative;
    transition: background-color 0.2s ease;
}

.sts-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
    transition: transform 0.2s ease;
}

.sts-toggle.sts-toggle-on .sts-toggle-track,
.sts-menu-toggle.sts-toggle-on .sts-toggle-track {
    background: var(--sts-green);
}

.sts-toggle.sts-toggle-on .sts-toggle-thumb,
.sts-menu-toggle.sts-toggle-on .sts-toggle-thumb {
    transform: translateX(20px);
}

/* Locked toggle indicator */
.sts-menu-toggle.sts-toggle-locked .sts-toggle-track::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 12px;
    background: var(--sts-text-tertiary);
    border-radius: 2px;
}

/* Danger items (red text) */
.sts-item-danger .sts-item-label,
.sts-menu-item-danger .sts-menu-label {
    color: var(--sts-red);
}

/* Link items (blue text, centered) */
.sts-item-link .sts-item-label {
    color: var(--sts-blue);
}

.sts-item-link.sts-item-centered {
    justify-content: center;
}

.sts-item-link.sts-item-centered .sts-item-content {
    flex: none;
    text-align: center;
}

/* Info items (no navigation) */
.sts-item-info {
    cursor: default;
}

.sts-item-info:active {
    background: transparent;
}

/* Loading State */
.sts-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--sts-text-secondary);
    font-size: 15px;
}

/* Menu description box */
.sts-menu-description {
    font-size: 13px;
    color: var(--sts-text-secondary);
    line-height: 1.5;
    padding: 10px 16px 20px;
}

/* Error state */
.sts-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--sts-red);
    font-size: 15px;
}

/* Home Indicator */
.sts-home-indicator {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 134px;
    height: 5px;
    background: var(--sts-text-primary);
    border-radius: 3px;
    opacity: 0.3;
}

/* Modal */
.sts-modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.sts-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sts-modal-content {
    position: relative;
    background: var(--sts-bg-secondary);
    border-radius: 14px 14px 0 0;
    width: 100%;
    max-height: 70%;
    display: flex;
    flex-direction: column;
    animation: sts-modal-slide-up 0.3s ease;
}

@keyframes sts-modal-slide-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.sts-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 0.5px solid var(--sts-separator);
}

.sts-modal-header h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--sts-text-primary);
    margin: 0;
}

.sts-modal-close {
    background: var(--sts-bg-tertiary);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    color: var(--sts-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sts-modal-close:hover {
    background: var(--sts-text-tertiary);
}

.sts-modal-body {
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sts-modal-body p {
    font-size: 15px;
    line-height: 1.5;
    color: var(--sts-text-primary);
    margin: 0 0 12px;
}

.sts-modal-body p:last-child {
    margin-bottom: 0;
}

/* Modal list styling */
.sts-modal-list {
    margin: 0 0 12px;
    padding-left: 20px;
}

.sts-modal-list li {
    font-size: 15px;
    line-height: 1.5;
    color: var(--sts-text-primary);
    margin-bottom: 4px;
}

/* Modal note (e.g., "This is a toggle setting") */
.sts-modal-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px;
    background: var(--sts-bg-tertiary);
    border-radius: 8px;
    font-size: 13px;
    color: var(--sts-text-secondary);
}

.sts-modal-note-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sts-modal-note-icon svg {
    width: 20px;
    height: 12px;
    stroke: var(--sts-green);
}

/* Menu Transitions */
.sts-menu-enter {
    animation: sts-slide-in-right 0.3s ease forwards;
}

.sts-menu-exit {
    animation: sts-slide-out-left 0.3s ease forwards;
}

.sts-menu-enter-back {
    animation: sts-slide-in-left 0.3s ease forwards;
}

.sts-menu-exit-back {
    animation: sts-slide-out-right 0.3s ease forwards;
}

@keyframes sts-slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes sts-slide-out-left {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-30%);
        opacity: 0;
    }
}

@keyframes sts-slide-in-left {
    from {
        transform: translateX(-30%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes sts-slide-out-right {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Checkmark for selected options */
.sts-item-checkmark {
    color: var(--sts-blue);
    width: 14px;
    height: 14px;
}

.sts-item-checkmark svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

/* Button style items */
.sts-button-item {
    background: var(--sts-bg-secondary);
    border-radius: var(--sts-border-radius);
    margin-bottom: 8px;
}

.sts-button-item .sts-menu-item {
    justify-content: center;
}

.sts-button-item .sts-menu-item::after {
    display: none;
}

/* Description text under items */
.sts-item-description {
    font-size: 13px;
    color: var(--sts-text-secondary);
    line-height: 1.4;
    padding: 8px 16px 0;
}

/* Responsive adjustments */
@media (max-width: 420px) {
    .sts-container {
        padding: 10px;
    }

    .sts-container.sts-size-medium {
        --sts-frame-width: calc(100vw - 20px);
        --sts-frame-height: calc((100vw - 20px) * 2.165);
    }

    .sts-iphone-frame {
        border-radius: 40px;
        box-shadow:
            0 0 0 8px #1a1a1a,
            0 0 0 10px #3a3a3a,
            0 15px 30px rgba(0, 0, 0, 0.25);
    }
}

/* Print styles - hide simulator */
@media print {
    .sts-container {
        display: none;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .sts-menu-enter,
    .sts-menu-exit,
    .sts-menu-enter-back,
    .sts-menu-exit-back,
    .sts-modal-content {
        animation: none;
    }

    .sts-toggle::after {
        transition: none;
    }
}

