/* iPhone Simulator Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* iPhone Frame */
.iphone-frame {
    width: 375px;
    height: 812px;
    background: #000;
    border-radius: 40px;
    padding: 8px;
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

/* Status Bar */
.status-bar {
    height: 44px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 20px 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    position: relative;
    z-index: 1000;
}

.status-left .time {
    font-weight: 700;
}

.status-center .notch {
    width: 150px;
    height: 30px;
    background: #000;
    border-radius: 0 0 15px 15px;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

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

.status-right i {
    font-size: 12px;
}

/* Screen Container */
.screen-container {
    height: calc(100% - 44px);
    position: relative;
    overflow: hidden;
    border-radius: 32px;
}

/* Screen Base */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    background: #000;
}

.screen.active {
    opacity: 1;
    transform: translateX(0);
}

.screen.sliding-out {
    transform: translateX(-100%);
}

/* Home Screen */
#home-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.wallpaper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../BG.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.95;
}

/* App Grid */
.app-grid {
    padding: 40px 20px 0;
    position: relative;
    z-index: 10;
}

.app-row {
    display: flex;
    justify-content: space-around;
    margin-bottom: 40px;
}

.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.app-icon:active {
    transform: scale(0.9);
}

.icon-bg {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    margin-bottom: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.app-name {
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* App Icon Colors */
.photos-icon { background: linear-gradient(135deg, #ff6b6b, #ee5a24); }
.mail-icon { background: linear-gradient(135deg, #0984e3, #74b9ff); }
.settings-icon { background: linear-gradient(135deg, #636e72, #2d3436); }
.safari-icon { background: linear-gradient(135deg, #00cec9, #55efc4); }
.messages-icon { background: linear-gradient(135deg, #00b894, #55efc4); }
.phone-icon { background: linear-gradient(135deg, #00b894, #00cec9); }
.calendar-icon { background: linear-gradient(135deg, #fd79a8, #fdcb6e); }
.camera-icon { background: linear-gradient(135deg, #2d3436, #636e72); }

/* Dock */
.dock {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dock-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dock-apps {
    display: flex;
    gap: 20px;
    position: relative;
    z-index: 2;
}

.dock-app .icon-bg {
    width: 50px;
    height: 50px;
    font-size: 24px;
}

.dock-app .app-name {
    display: none;
}

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

/* App Header */
.app-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
}

.back-btn, .menu-btn, .share-btn {
    background: none;
    border: none;
    color: #007AFF;
    font-size: 18px;
    padding: 8px;
    cursor: pointer;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.back-btn:active, .menu-btn:active, .share-btn:active {
    opacity: 0.5;
}

/* App Content */
.app-content {
    height: calc(100% - 60px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Photos App */
.photos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
}

.photo-item {
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.photo-item:active img {
    transform: scale(0.95);
}

.no-photos, .no-mail {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #666;
    gap: 10px;
}

.no-photos i, .no-mail i {
    font-size: 48px;
    opacity: 0.5;
}

/* Mail App */
.mail-list {
    background: #000;
}

.mail-item {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background-color 0.2s;
}

.mail-item:active {
    background: rgba(255, 255, 255, 0.05);
}

.mail-item.unread {
    background: rgba(0, 122, 255, 0.05);
}

.mail-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: #007AFF;
    border-radius: 0 2px 2px 0;
}

.mail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;
}

.mail-sender {
    color: #fff;
    font-weight: 600;
    font-size: 16px;
}

.mail-date {
    color: #666;
    font-size: 14px;
    white-space: nowrap;
}

.mail-subject {
    color: #fff;
    font-size: 15px;
    margin-bottom: 5px;
    font-weight: 500;
}

.mail-preview {
    color: #999;
    font-size: 14px;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Photo Viewer */
#photo-viewer {
    background: #000;
}

.photo-viewer-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    z-index: 100;
}

.photo-viewer-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 0;
}

.photo-viewer-content img {
    max-width: 100%;
    max-height: 70%;
    object-fit: contain;
}

.photo-info {
    padding: 20px;
    text-align: center;
}

.photo-info h3 {
    color: #fff;
    font-size: 18px;
    margin-bottom: 10px;
}

.photo-info p {
    color: #999;
    font-size: 14px;
    line-height: 1.4;
}

/* Mail Viewer */
.mail-viewer-content {
    background: #000;
    color: #fff;
    min-height: 100%;
}

.mail-header-info {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sender-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sender-info strong {
    color: #fff;
    font-size: 16px;
}

.sender-info span {
    color: #666;
    font-size: 14px;
}

.mail-content {
    padding: 20px;
    line-height: 1.6;
    color: #fff;
    white-space: pre-wrap;
}



/* Responsive adjustments for iPhone */
@media (max-width: 414px) {
    .iphone-frame {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        padding: 0;
    }
    
    .screen-container {
        border-radius: 0;
    }
    
    .status-bar {
        padding: 0 15px 8px;
    }
}

/* Touch optimizations */
@media (pointer: coarse) {
    .app-icon {
        padding: 10px;
    }
    
    .mail-item {
        padding: 20px;
    }
    
    .admin-form input,
    .admin-form textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Calendar App Styles */
.calendar-header {
    padding: 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.calendar-header h2 {
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    text-transform: capitalize;
}

.calendar-grid {
    padding: 0;
    background: #111;
}

.calendar-header-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #222;
    border-bottom: 1px solid #333;
}

.calendar-day-header {
    padding: 10px 5px;
    text-align: center;
    color: #999;
    font-size: 12px;
    font-weight: 600;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #333;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
}

.calendar-day:hover {
    background: rgba(255, 255, 255, 0.05);
}

.calendar-day.other-month .day-number {
    color: #555;
}

.calendar-day.current-month .day-number {
    color: #fff;
}

.calendar-day.today {
    background: rgba(0, 122, 255, 0.2);
}

.calendar-day.today .day-number {
    background: #007AFF;
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-day.has-events::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 6px;
    height: 6px;
    background: #ff9500;
    border-radius: 50%;
}

.day-number {
    font-size: 14px;
    font-weight: 500;
}

.events-list {
    padding: 20px;
    background: #000;
    max-height: 300px;
    overflow-y: auto;
}

.events-list h3 {
    color: #fff;
    font-size: 18px;
    margin-bottom: 15px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.event-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: #222;
    border-radius: 8px;
    border-left: 4px solid #007AFF;
}

.event-item.patrol {
    border-left-color: #34c759;
}

.event-item.training {
    border-left-color: #ff9500;
}

.event-item.meeting {
    border-left-color: #af52de;
}

.event-item.operation {
    border-left-color: #ff3b30;
}

.event-time {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
    margin-right: 12px;
}

.event-info {
    flex: 1;
}

.event-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.event-description {
    color: #999;
    font-size: 12px;
    line-height: 1.3;
    margin-bottom: 4px;
}

.event-date {
    color: #666;
    font-size: 11px;
}

.event-type-icon {
    color: #666;
    font-size: 16px;
    margin-left: 10px;
}

/* Messages App Styles */
.messages-list {
    background: #000;
}

.message-conversation-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.message-conversation-item:active {
    background: rgba(255, 255, 255, 0.05);
}

.message-conversation-item.unread {
    background: rgba(0, 122, 255, 0.05);
}

.conversation-avatar {
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background: linear-gradient(135deg, #007AFF, #34C759);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: #fff;
    font-size: 20px;
}

.conversation-info {
    flex: 1;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.conversation-contact {
    color: #fff;
    font-weight: 600;
    font-size: 16px;
}

.conversation-time {
    color: #666;
    font-size: 14px;
}

.conversation-preview {
    color: #999;
    font-size: 14px;
    line-height: 1.3;
}

.unread-indicator {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: #007AFF;
    border-radius: 50%;
}

/* Message Conversation Styles */
.messages-conversation {
    padding: 20px;
    background: #000;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.message-bubble.sent {
    align-self: flex-end;
    background: #007AFF;
    color: #fff;
    margin-left: auto;
}

.message-bubble.received {
    align-self: flex-start;
    background: #333;
    color: #fff;
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
    margin-bottom: 4px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    text-align: right;
}

.message-bubble.received .message-time {
    text-align: left;
}

/* Safari App Styles */
.safari-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 40px 20px;
}

.safari-message {
    text-align: center;
    color: #fff;
}

.safari-icon-large {
    font-size: 80px;
    color: #007AFF;
    margin-bottom: 20px;
    display: block;
}

.safari-message h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: #fff;
}

.safari-message p {
    font-size: 16px;
    line-height: 1.5;
    color: #999;
    margin-bottom: 30px;
}

.safari-open-btn {
    background: #007AFF;
    color: #fff;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 auto;
}

.safari-open-btn:hover {
    background: #0056b3;
}

.safari-open-btn:active {
    transform: scale(0.98);
}

/* No content states */
.no-photos, .no-mail, .no-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #666;
    gap: 10px;
}

.no-photos i, .no-mail i, .no-messages i {
    font-size: 48px;
    opacity: 0.5;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

/* Loading states */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
    color: #666;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #333;
    border-top: 2px solid #007AFF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Locked photos */
.locked {
    position: relative;
}

.locked img {
    filter: blur(5px);
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}