/* CSS Variables - Phony.cam Design System */
:root {
    --bg: #000000;
    --bg-soft: #050505;
    --bg-elevated: #0a0a0a;
    
    --glass-1: rgba(255, 255, 255, 0.045);
    --glass-2: rgba(255, 255, 255, 0.07);
    --glass-3: rgba(255, 255, 255, 0.10);
    --glass-4: rgba(255, 255, 255, 0.14);
    
    --rim: rgba(255, 255, 255, 0.10);
    --rim-strong: rgba(255, 255, 255, 0.18);
    --rim-bright: rgba(255, 255, 255, 0.32);
    
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-muted: #6e6e73;
    --text-faint: rgba(245, 245, 247, 0.32);
    
    --success: #00ff88;
    --warning: #ffaa00;
    --error: #ff4444;
    --call-green: #00d96b;
    --call-red: #ff3b30;
    
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --radius-pill: 999px;
    
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 24px 48px -16px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 32px 64px -24px rgba(0, 0, 0, 0.8);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow-x: hidden;
}

/* Background */
.animated-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s ease-in-out infinite;
    will-change: transform;
}

.orb-1 {
    width: 600px;
    height: 600px;
    top: -180px;
    left: -120px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08), transparent);
}

.orb-2 {
    width: 520px;
    height: 520px;
    top: 30%;
    right: -160px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.06), transparent);
    animation-delay: -10s;
}

.orb-3 {
    width: 720px;
    height: 720px;
    bottom: -260px;
    left: 28%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05), transparent);
    animation-delay: -20s;
    opacity: 0.5;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 1;
    pointer-events: none;
}

/* Screen */
.screen {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
}

/* Auth */
.auth-container {
    background: var(--glass-2);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border: 1px solid var(--rim);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.logo-section {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background: var(--glass-3);
    border: 1px solid var(--rim-strong);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: var(--shadow-sm);
}

.logo-icon svg {
    width: 32px;
    height: 32px;
}

.logo-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
    background: linear-gradient(100deg, #ffffff 0%, #ffffff 40%, rgba(255,255,255,0.55) 50%, #ffffff 60%, #ffffff 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.logo-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.login-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-divider {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    position: relative;
    margin: 4px 0;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--rim);
}

.auth-divider span {
    position: relative;
    background: var(--bg);
    padding: 0 16px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.form-group input {
    background: var(--glass-1);
    border: 1px solid var(--rim);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
}

.form-group input:focus {
    outline: none;
    border-color: var(--rim-bright);
    background: var(--glass-2);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 14px 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1;
}

.btn-primary {
    background: var(--text);
    color: var(--bg);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 255, 255, 0.2);
}

.btn-secondary {
    background: var(--glass-2);
    color: var(--text);
    border: 1px solid var(--rim);
}

.btn-secondary:hover {
    background: var(--glass-3);
    border-color: var(--rim-strong);
}

.btn-block {
    width: 100%;
}

.error-message {
    color: var(--error);
    font-size: 13px;
    text-align: center;
    min-height: 18px;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid transparent;
}

.auth-footer a:hover {
    border-bottom-color: var(--text);
}

/* Phone Container */
.phone-container {
    background: var(--glass-2);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border: 1px solid var(--rim);
    border-radius: var(--radius-xl);
    padding: 24px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.phone-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

/* Header */
.phone-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--rim);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.user-avatar {
    width: 44px;
    height: 44px;
    background: var(--glass-3);
    border: 1px solid var(--rim);
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
}

.user-display-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.user-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
}

.status-dot.connecting {
    background: var(--warning);
    animation: pulse 1.5s infinite;
}

.status-dot.in-call {
    background: var(--call-green);
    animation: pulse 1.5s infinite;
}

.status-dot.ringing {
    background: var(--warning);
    animation: pulse 0.6s infinite;
}

.status-dot.error {
    background: var(--error);
}

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

.header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-icon {
    width: 36px;
    height: 36px;
    background: var(--glass-1);
    border: 1px solid var(--rim);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text);
    text-decoration: none;
}

.btn-icon:hover {
    background: var(--glass-2);
    border-color: var(--rim-strong);
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* Call Status */
.call-status-card {
    text-align: center;
    margin-bottom: 16px;
    min-height: 60px;
    padding: 8px 0;
}

.call-state {
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.call-timer {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
    min-height: 32px;
}

.remote-display {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
    font-variant-numeric: tabular-nums;
}

/* Caller ID selector */
.callerid-selector {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.callerid-selector label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.callerid-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.callerid-select {
    flex: 1;
    background: var(--glass-1);
    border: 1px solid var(--rim);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none'><path d='M6 9l6 6 6-6' stroke='%23a1a1a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.callerid-select:focus {
    outline: none;
    border-color: var(--rim-strong);
    background-color: var(--glass-2);
}

.callerid-select option {
    background: var(--bg-elevated);
    color: var(--text);
}

.btn-icon-small {
    width: 36px;
    height: 36px;
    background: var(--glass-1);
    border: 1px solid var(--rim);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text);
    flex-shrink: 0;
}

.btn-icon-small:hover {
    background: var(--glass-2);
    border-color: var(--rim-strong);
}

.btn-icon-small svg {
    width: 16px;
    height: 16px;
}

/* Number Display */
.number-display {
    position: relative;
    margin-bottom: 16px;
}

#phone-number {
    width: 100%;
    background: var(--glass-1);
    border: 1px solid var(--rim);
    border-radius: var(--radius-md);
    padding: 16px 56px 16px 20px;
    color: var(--text);
    font-family: inherit;
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    letter-spacing: 1px;
    -webkit-appearance: none;
    appearance: none;
}

#phone-number:focus {
    outline: none;
    border-color: var(--rim-strong);
    background: var(--glass-2);
}

#phone-number::placeholder {
    color: var(--text-faint);
    font-weight: 400;
}

.btn-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-clear:hover {
    background: var(--glass-2);
    color: var(--text);
}

.btn-clear svg {
    width: 20px;
    height: 20px;
}

/* Numpad */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.numpad-btn {
    background: var(--glass-1);
    border: 1px solid var(--rim);
    border-radius: var(--radius-md);
    padding: 14px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 64px;
    -webkit-appearance: none;
    appearance: none;
    color: var(--text);
}

.numpad-btn:hover {
    background: var(--glass-2);
    border-color: var(--rim-strong);
}

.numpad-btn:active {
    background: var(--glass-3);
    transform: scale(0.95);
}

.numpad-btn .digit {
    font-size: 26px;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

.numpad-btn .letters {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Phone Actions */
.phone-actions {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 16px;
    padding: 8px 0;
    margin-bottom: 16px;
}

.action-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid var(--rim);
    background: var(--glass-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
}

.action-btn:hover {
    background: var(--glass-3);
    border-color: var(--rim-strong);
    transform: scale(1.05);
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.action-btn svg {
    width: 22px;
    height: 22px;
}

.action-btn[aria-pressed="true"] {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

.action-call {
    width: 68px;
    height: 68px;
    background: var(--call-green);
    border-color: var(--call-green);
    box-shadow: 0 8px 24px rgba(0, 217, 107, 0.3);
}

.action-call:hover {
    background: var(--call-green);
    border-color: var(--call-green);
    box-shadow: 0 12px 32px rgba(0, 217, 107, 0.4);
}

.action-call svg {
    width: 28px;
    height: 28px;
    color: white;
}

.action-call:disabled {
    background: var(--glass-3);
    border-color: var(--rim);
    box-shadow: none;
}

.action-call:disabled svg {
    color: var(--text-muted);
}

.action-hangup {
    width: 68px;
    height: 68px;
    background: var(--call-red);
    border-color: var(--call-red);
    box-shadow: 0 8px 24px rgba(255, 59, 48, 0.3);
}

.action-hangup:hover {
    background: var(--call-red);
    border-color: var(--call-red);
    box-shadow: 0 12px 32px rgba(255, 59, 48, 0.4);
}

.action-hangup svg {
    width: 28px;
    height: 28px;
    color: white;
}

/* Info Strip */
.info-strip {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--glass-1);
    border: 1px solid var(--rim);
    border-radius: var(--radius-sm);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.info-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.info-value {
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
}

.info-value.mono {
    font-family: 'SF Mono', Monaco, monospace;
}

/* Modal (incoming call) */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--glass-3);
    border: 1px solid var(--rim-strong);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    text-align: center;
    width: 100%;
    max-width: 360px;
    animation: modal-pulse 1.5s infinite;
}

@keyframes modal-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 217, 107, 0.4); }
    50% { box-shadow: 0 0 0 24px rgba(0, 217, 107, 0); }
}

.incoming-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--glass-3);
    border: 2px solid var(--rim-strong);
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.incoming-avatar svg {
    width: 36px;
    height: 36px;
}

.modal-content h3 {
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.incoming-from {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 32px;
    word-break: break-all;
}

.incoming-actions {
    display: flex;
    justify-content: space-around;
    gap: 24px;
}

/* Toast */
.toast-container {
    position: fixed;
    top: calc(20px + var(--safe-top));
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--glass-3);
    backdrop-filter: blur(20px);
    border: 1px solid var(--rim);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text);
    box-shadow: var(--shadow-md);
    animation: toast-in 0.3s ease;
    max-width: 320px;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

.toast.success { border-color: rgba(0, 255, 136, 0.3); }
.toast.error { border-color: rgba(255, 68, 68, 0.3); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.hidden { display: none !important; }

/* Mobile */
@media (max-width: 480px) {
    .screen { padding: 16px; }
    
    .auth-container {
        padding: 32px 24px;
        border-radius: var(--radius-lg);
    }
    
    .logo-title { font-size: 22px; }
    
    .phone-container {
        padding: 20px 16px;
        border-radius: var(--radius-lg);
    }
    
    .phone-header {
        margin-bottom: 16px;
        padding-bottom: 12px;
    }
    
    .user-display-name { font-size: 13px; }
    
    .call-timer { font-size: 22px; }
    
    #phone-number { font-size: 20px; padding: 14px 50px 14px 16px; }
    
    .numpad-btn { min-height: 56px; padding: 10px 0; }
    .numpad-btn .digit { font-size: 22px; }
    .numpad-btn .letters { font-size: 9px; }
    
    .action-btn { width: 50px; height: 50px; }
    .action-call, .action-hangup { width: 60px; height: 60px; }
    .action-btn svg { width: 20px; height: 20px; }
    .action-call svg, .action-hangup svg { width: 24px; height: 24px; }
    
    .toast-container {
        left: 12px;
        right: 12px;
        top: calc(12px + var(--safe-top));
    }
    
    .info-strip { padding: 10px 14px; }
    .info-value { font-size: 12px; }
}

@media (max-width: 380px) {
    .numpad { gap: 8px; }
    .numpad-btn { min-height: 52px; }
    .numpad-btn .digit { font-size: 20px; }
    
    .action-btn { width: 46px; height: 46px; }
    .action-call, .action-hangup { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .gradient-orb { animation: none; }
}
