:root {
    --bg-color: #050505;
    --card-bg: rgba(25, 25, 25, 0.6);
    --text-main: #fcfcfc;
    --text-muted: #888888;
    --accent: #d4af37;
    --accent-hover: #bda030;
    --border: rgba(255, 255, 255, 0.1);
    --nav-height: 75px;
    --header-height: 70px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: stretch;
}

#app-container {
    width: 100%;
    max-width: 480px;
    background-color: #0a0a0a;
    position: relative;
    overflow: hidden;
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0,0,0,0.8);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.screen {
    display: none;
    height: 100%;
    flex-direction: column;
    overflow: hidden;
}

.screen.active {
    display: flex;
}

/* Auth Screen */
#auth-screen {
    padding: 1.5rem;
    padding-top: max(1.5rem, env(safe-area-inset-top, 0px));
    justify-content: center;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.logo {
    font-size: 2.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
    letter-spacing: -1px;
}

.logo span {
    color: var(--accent);
}

h2 {
    font-weight: 600;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

input, textarea {
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.8rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    -webkit-user-select: text;
    user-select: text;
}

input:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.1);
    background-color: rgba(30, 30, 30, 0.8);
}

.btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.3s;
}

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

.primary-btn {
    background-color: var(--accent);
    color: #000;
    margin-top: 0.8rem;
}

.primary-btn:hover {
    background-color: var(--accent-hover);
}

.action-btn {
    background-color: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--accent);
    margin-bottom: 1rem;
    padding: 1.2rem;
    font-size: 1rem;
    backdrop-filter: blur(5px);
}

.action-btn.secondary {
    border-color: var(--border);
}

.action-btn.secondary:hover {
    border-color: #555;
    background-color: rgba(40,40,40,0.8);
}

.action-btn:not(.secondary):hover {
    background-color: rgba(212, 175, 55, 0.1);
}

/* Main Screen */
header {
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    padding-top: max(1rem, env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--border);
    background-color: rgba(10,10,10,0.8);
    backdrop-filter: blur(12px);
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: var(--header-height);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

#header-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.badge {
    background-color: var(--accent);
    color: #000;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
}

.bell-btn {
    background: transparent;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.bell-btn svg {
    width: 24px;
    height: 24px;
    stroke: var(--accent);
}

.bell-btn:hover {
    background: rgba(212, 175, 55, 0.1);
}

.bell-btn:active {
    transform: scale(0.92);
}

.bell-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ff3b30;
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

main {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 1.2rem 1.5rem;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 0.5rem);
    min-height: 0;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.card .brand {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.card .plate {
    color: var(--text-muted);
}

.status-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 0.8rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    position: relative;
    overflow: hidden;
}

.status-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(90deg, rgba(212,175,55,0.05) 0%, transparent 100%);
    pointer-events: none;
}

.status-card .title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.4rem;
}

.status-card .time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0;
    font-size: 1rem;
}

/* Bottom Nav */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background-color: rgba(5, 5, 5, 0.95);
    backdrop-filter: blur(15px);
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    flex-shrink: 0;
    z-index: 20;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 25%;
    height: 100%;
    padding: 0.3rem 0;
}

.nav-item.active {
    color: var(--accent);
}

.nav-item.active .icon {
    transform: translateY(-2px);
}

.nav-item .icon {
    font-size: 1.3rem;
    margin-bottom: 0.2rem;
    transition: transform 0.3s ease;
}

.nav-item .label {
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Chat Styling */
.chat-container, .chat-box {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 0.8rem;
    height: calc(100% - 180px);
    min-height: 120px;
    max-height: calc(100dvh - var(--header-height) - var(--nav-height) - 200px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0.8rem;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chat-bubble {
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    max-width: 80%;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
    flex-shrink: 0;
}

.chat-bubble.customer {
    background-color: transparent;
    border: 1px solid var(--accent);
    align-self: flex-start;
    border-bottom-left-radius: 0;
}

.chat-bubble.operator {
    background-color: var(--accent);
    color: #000;
    align-self: flex-end;
    border-bottom-right-radius: 0;
}

.chat-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-form input,
.chat-form textarea {
    margin-bottom: 0;
    flex: 1;
    min-height: 60px;
    max-height: 120px;
    resize: none;
    line-height: 1.5;
    padding: 0.8rem;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
}

.chat-form button {
    width: auto;
    margin-top: 0;
    margin-bottom: 0;
    padding: 0.7rem 1rem;
    align-self: flex-end;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.chat-select .card {
    cursor: pointer;
    transition: border 0.2s;
}

.chat-select .card:hover {
    border-color: var(--accent);
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: max(20px, env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background-color: var(--card-bg);
    border-left: 4px solid var(--accent);
    box-shadow: 0 4px 20px rgba(0,0,0,0.8);
    padding: 1rem;
    border-radius: 8px;
    backdrop-filter: blur(15px);
    animation: slideDown 0.4s ease forwards, fadeOut 0.4s ease 4.6s forwards;
}

.toast .toast-title {
    font-weight: 700;
    margin-bottom: 0.3rem;
    color: var(--text-main);
    font-size: 1rem;
}

.toast .toast-message {
    font-size: 0.85rem;
    color: var(--text-muted);
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

/* Modal Overlays */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    width: 100dvw;
    height: 100dvh;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease forwards;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal {
    background: var(--card-bg);
    border: 1px solid var(--accent);
    padding: 1.5rem;
    border-radius: 16px;
    width: 85%;
    max-width: 400px;
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,1);
    transform: scale(0.9);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes popIn {
    to { transform: scale(1); }
}
