/* =====================================================
   OPS Phone - iPhone WebApp Styles
   ===================================================== */

:root {
    --primary: #007AFF;
    --primary-dark: #0056b3;
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f3460;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;
    --call-green: #34c759;
    --call-red: #ff3b30;
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* =====================================================
   Loading Animation
   ===================================================== */

#startanimation {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--bg-input);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =====================================================
   Screens
   ===================================================== */

.screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
}

/* =====================================================
   Login Screen
   ===================================================== */

#screen_login {
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-card) 100%);
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

.login_container {
    width: 100%;
    max-width: 340px;
}

.login_header {
    text-align: center;
    margin-bottom: 40px;
}

.login_logo {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.login_subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.login_form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input_group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input_group label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.input_group input {
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 16px;
    font-size: 18px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.input_group input:focus {
    border-color: var(--primary);
}

.input_group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.btn_primary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: none;
    border-radius: 12px;
    padding: 16px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn_primary.button-active {
    background: var(--primary);
    color: white;
}

.btn_primary:active {
    transform: scale(0.98);
}

.btn_secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--bg-input);
    border-radius: 12px;
    padding: 14px;
    font-size: 15px;
    cursor: pointer;
}

.login_lockbar {
    background: var(--danger);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    text-align: center;
    margin-top: 20px;
}

/* =====================================================
   Main App Screen
   ===================================================== */

#screen_main {
    background: var(--bg-dark);
}

/* Header */
.app_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: calc(var(--safe-top) + 12px);
    background: var(--bg-card);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.header_user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.header_user_icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--success);
}

.header_user_icon.status_busy {
    border-color: var(--danger);
}

.header_user_icon.status_ring {
    border-color: var(--warning);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#header_user_name {
    font-size: 15px;
    font-weight: 600;
}

.header_status {
    padding: 0 12px;
}

.header_cloud {
    width: 24px;
    height: 24px;
    opacity: 0.6;
}

.header_cloud.connected {
    opacity: 1;
}

.header_menu {
    padding: 8px;
    cursor: pointer;
}

.header_menu_icon {
    width: 24px;
    height: 24px;
    filter: invert(1);
}

/* Tab Navigation */
.tab_nav {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.tab_item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.tab_item.tab_active {
    color: var(--primary);
}

.tab_icon {
    width: 24px;
    height: 24px;
    filter: invert(0.6);
}

.tab_item.tab_active .tab_icon {
    filter: invert(0.4) sepia(1) saturate(5) hue-rotate(190deg);
}

.tab_item span {
    font-size: 11px;
    font-weight: 500;
}

/* Content Area */
.content_area {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* =====================================================
   Dialpad View
   ===================================================== */

#view_dialpad {
    padding: 20px;
    padding-bottom: 20px;
}

.phone_pad {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 320px;
    margin: 0 auto;
    width: 100%;
}

.phonedisplay {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

#phone_placeholder {
    font-size: 24px;
    color: var(--text-secondary);
    opacity: 0.5;
}

#phone_dialnumber {
    font-size: 32px;
    font-weight: 300;
    letter-spacing: 2px;
    display: none;
}

.phonedialpad {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.phone_dpline {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.phone_dp {
    width: 75px;
    height: 75px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.15s;
}

.phone_dp:active {
    background: var(--bg-input);
    transform: scale(0.95);
}

.dp_sub {
    font-size: 10px;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-top: -2px;
}

.phone_cmdline {
    margin-top: 10px;
}

.phone_dp_cmd {
    background: transparent;
}

.phone_dp_icon {
    width: 28px;
    height: 28px;
    filter: invert(1);
}

.phone_dp_disabled {
    opacity: 0.3;
    pointer-events: none;
}

.phone_dp_del {
    opacity: 1;
    pointer-events: auto;
}

.phone_dp_dial {
    background: var(--call-green) !important;
    opacity: 1;
    pointer-events: auto;
}

.phone_dp_spacer {
    visibility: hidden;
}

/* =====================================================
   Call Display
   ===================================================== */

.phone_call {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-card) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    padding-top: calc(var(--safe-top) + 40px);
    padding-bottom: calc(var(--safe-bottom) + 40px);
    z-index: 100;
}

.call_info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.call_callerpic {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
}

.call_state {
    font-size: 16px;
    color: var(--text-secondary);
}

.call_name {
    font-size: 28px;
    font-weight: 600;
}

.call_number {
    font-size: 18px;
    color: var(--text-secondary);
}

.call_timer {
    font-size: 20px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.call_controls {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 20px;
}

.call_btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.call_btn:active {
    transform: scale(0.95);
}

.call_btn img {
    width: 32px;
    height: 32px;
    filter: invert(1);
}

.call_btn_green {
    background: var(--call-green);
}

.call_btn_red {
    background: var(--call-red);
}

.call_btn_active {
    background: var(--primary);
}

/* =====================================================
   Calls View (Anrufliste)
   ===================================================== */

#view_calls {
    padding-bottom: 10px;
}

.calls_filter {
    display: flex;
    padding: 12px 16px;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter_btn {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--bg-card);
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.filter_btn.filter_active {
    background: var(--primary);
    color: white;
}

.calls_list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.calls_empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.call_item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
}

.call_item:active {
    background: rgba(255,255,255,0.05);
}

.call_item_pic {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.call_item_info {
    flex: 1;
    min-width: 0;
}

.call_item_name {
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call_item_meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.call_item_type {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.call_item_type.answered { background: rgba(52, 199, 89, 0.2); color: var(--success); }
.call_item_type.missed { background: rgba(255, 59, 48, 0.2); color: var(--danger); }
.call_item_type.redial { background: rgba(0, 122, 255, 0.2); color: var(--primary); }
.call_item_type.busy { background: rgba(255, 149, 0, 0.2); color: var(--warning); }

.call_item_time {
    font-size: 12px;
    color: var(--text-secondary);
}

.call_item_action {
    padding: 10px;
    cursor: pointer;
}

.call_item_action img {
    width: 24px;
    height: 24px;
    filter: invert(0.4) sepia(1) saturate(5) hue-rotate(100deg);
}

/* =====================================================
   Menu Overlay
   ===================================================== */

.menu_overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.menu_overlay.show {
    display: flex;
    opacity: 1;
}

.menu_panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background: var(--bg-card);
    padding-top: var(--safe-top);
    transform: translateX(100%);
    transition: transform 0.3s;
}

.menu_overlay.show .menu_panel {
    transform: translateX(0);
}

.menu_header {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.menu_header span {
    display: block;
}

#menu_user_name {
    font-size: 18px;
    font-weight: 600;
}

#menu_user_nr {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.menu_items {
    padding: 10px 0;
}

.menu_item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.menu_item:active {
    background: rgba(255,255,255,0.05);
}

.menu_item img {
    width: 24px;
    height: 24px;
    filter: invert(0.7);
}

.menu_item span {
    font-size: 16px;
}

.menu_status {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-secondary);
}

.menu_status.active {
    color: var(--success);
}

.menu_separator {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 10px 16px;
}

.menu_item_logout {
    color: var(--danger);
}

.menu_item_logout img {
    filter: invert(0.4) sepia(1) saturate(5) hue-rotate(-30deg);
}

/* =====================================================
   Info/Error Boxes
   ===================================================== */

.infobox, .errorbox {
    position: fixed;
    bottom: calc(var(--safe-bottom) + 80px);
    left: 20px;
    right: 20px;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 14px;
    text-align: center;
    z-index: 300;
    display: none;
}

.infobox {
    background: var(--primary);
    color: white;
}

.errorbox {
    background: var(--danger);
    color: white;
}

@keyframes info_in {
    0% { opacity: 0; transform: translateY(20px); }
    10% { opacity: 1; transform: translateY(0); }
    90% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* =====================================================
   Utility Classes
   ===================================================== */

.hidden {
    display: none !important;
}

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

.search_bar {
    position: relative;
    flex-shrink: 0;
    padding: 12px 16px;
    padding-bottom: calc(var(--safe-bottom) + 12px);
    background: var(--bg-card);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.search_input_wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: 12px;
    padding: 0 14px;
    gap: 10px;
}

.search_icon {
    width: 20px;
    height: 20px;
    filter: invert(0.5);
    flex-shrink: 0;
}

#search_input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 14px 0;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
}

#search_input::placeholder {
    color: var(--text-secondary);
}

.search_clear {
    padding: 8px;
    cursor: pointer;
}

.search_clear img {
    width: 16px;
    height: 16px;
    filter: invert(0.5);
}

/* Search Results */
.search_results {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 50vh;
    background: var(--bg-card);
    border-top: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 49;
}

.search_result_item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
}

.search_result_item:active {
    background: rgba(255,255,255,0.05);
}

.search_result_pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.search_result_info {
    flex: 1;
    min-width: 0;
}

.search_result_name {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search_result_number {
    font-size: 13px;
    color: var(--text-secondary);
}

.search_result_type {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(0,122,255,0.2);
    color: var(--primary);
    flex-shrink: 0;
}

.search_result_type.intern {
    background: rgba(52, 199, 89, 0.2);
    color: var(--success);
}

.search_result_call {
    padding: 8px;
    flex-shrink: 0;
}

.search_result_call img {
    width: 24px;
    height: 24px;
    filter: invert(0.4) sepia(1) saturate(5) hue-rotate(100deg);
}

.search_empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.search_loading {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}
