/* ============================================ */
/* SECRETCHAT - MOBILE FIRST CSS               */
/* ============================================ */

/* CSS Variables */
:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --danger: #e74c3c;
    --success: #27ae60;
    --warning: #f39c12;
    --bg-dark: #1a1a2e;
    --bg-darker: #16213e;
    --bg-card: #0f3460;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --border-color: #2d3748;
    --shadow: 0 4px 6px rgba(0,0,0,0.3);
    --radius: 12px;
    --transition: all 0.3s ease;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

/* Screen Management */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
}

.screen.active {
    display: flex;
}

/* ============================================ */
/* AUTH SCREEN (Login/Register)                */
/* ============================================ */
#authScreen {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
}

.auth-container {
    width: 90%;
    max-width: 400px;
    padding: 30px 20px;
}

.logo-container {
    text-align: center;
    margin-bottom: 30px;
}

.logo-icon {
    font-size: 60px;
    margin-bottom: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.app-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}

.app-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.auth-tab.active {
    background: var(--primary);
    color: white;
}

/* Forms */
.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 16px;
    transition: var(--transition);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius);
    cursor: pointer;
}

.btn-success {
    background: var(--success);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius);
    cursor: pointer;
}

.full-width {
    width: 100%;
}

.auth-info {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ============================================ */
/* CHAT SCREEN                                */
/* ============================================ */
#chatScreen {
    flex-direction: column;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    gap: 8px;
}

.header-center {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-card);
}

/* Chat Wrapper */
.chat-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 100%;
    max-width: 350px;
    background: var(--bg-darker);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    font-size: 16px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
}

.chat-item:hover {
    background: var(--bg-card);
}

.chat-item.active {
    background: var(--primary);
}

.chat-item-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.chat-item-last {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-badge {
    background: var(--danger);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 8px;
}

.empty-state small {
    font-size: 12px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.welcome-screen h2 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* Message Bubbles */
.message-wrapper {
    display: flex;
    margin-bottom: 4px;
}

.message-wrapper.sent {
    justify-content: flex-end;
}

.message-wrapper.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.message-wrapper.sent .message-bubble {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-bottom-right-radius: 4px;
}

.message-wrapper.received .message-bubble {
    background: var(--bg-card);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.message-status {
    font-size: 10px;
    margin-left: 4px;
}

.message-status.read {
    color: #4fc3f7;
}

.message-expired {
    font-style: italic;
    color: var(--text-muted);
    text-align: center;
    padding: 8px;
    font-size: 12px;
}

.message-viewonce {
    background: var(--warning) !important;
    color: #000 !important;
    font-weight: 600;
}

/* Message Input Area */
.message-input-area {
    padding: 12px 16px;
    background: var(--bg-darker);
    border-top: 1px solid var(--border-color);
}

.expiry-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 12px;
}

.expiry-select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
}

.view-once-label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    cursor: pointer;
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.input-row textarea {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
}

.input-row textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

.send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* ============================================ */
/* MODALS                                     */
/* ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-darker);
    border-radius: var(--radius);
    width: 90%;
    max-width: 450px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
}

.modal-body {
    padding: 20px;
}

/* Modal Tabs */
.tab-container {
    display: flex;
    margin-bottom: 20px;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 4px;
}

.modal-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    transition: var(--transition);
}

.modal-tab.active {
    background: var(--primary);
    color: white;
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

/* Invite Code */
.invite-code-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-dark);
    padding: 16px;
    border-radius: var(--radius);
    margin: 16px 0;
}

.invite-code-display span {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 4px;
    flex: 1;
    text-align: center;
    color: var(--primary);
}

.copy-btn {
    background: var(--primary);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
}

.code-input {
    width: 100%;
    padding: 14px;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 20px;
    text-align: center;
    letter-spacing: 4px;
    margin: 16px 0;
}

.code-input:focus {
    border-color: var(--primary);
    outline: none;
}

.info-text {
    display: block;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 8px;
}

/* Safety Numbers */
.safety-numbers {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.safety-numbers span {
    background: var(--bg-dark);
    padding: 12px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 18px;
    text-align: center;
    letter-spacing: 2px;
}

.verify-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.verify-buttons button {
    flex: 1;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 2000;
    transition: transform 0.3s ease;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    text-align: center;
    max-width: 90%;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.warning {
    background: var(--warning);
    color: #000;
}

.toast.error {
    background: var(--danger);
}

.toast.success {
    background: var(--success);
}

/* ============================================ */
/* MOBILE SPECIFIC (Default)                  */
/* ============================================ */
.sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100vh;
    z-index: 200;
    transition: left 0.3s ease;
}

.sidebar.open {
    left: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 199;
}

.sidebar-overlay.active {
    display: block;
}

/* Hide desktop elements on mobile */
.desktop-only {
    display: none;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-wrapper {
    animation: fadeIn 0.3s ease;
}

/* ============================================ */
/* DESKTOP / TABLET (>= 768px)                 */
/* ============================================ */
@media (min-width: 768px) {
    .sidebar {
        position: relative;
        left: 0;
        height: auto;
        max-width: 320px;
        min-width: 280px;
    }
    
    .chat-wrapper {
        flex-direction: row;
    }
    
    .main-chat {
        min-width: 0;
    }
    
    #menuBtn {
        display: none;
    }
    
    .message-bubble {
        max-width: 60%;
    }
    
    .modal-content {
        max-width: 500px;
    }
    
    .desktop-only {
        display: block;
    }
    
    .auth-container {
        max-width: 420px;
    }
}

/* ============================================ */
/* LARGE DESKTOP (>= 1200px)                  */
/* ============================================ */
@media (min-width: 1200px) {
    .sidebar {
        max-width: 380px;
    }
    
    .message-bubble {
        max-width: 50%;
    }
    
    .chat-header {
        padding: 16px 24px;
    }
    
    .messages-container {
        padding: 24px 32px;
    }
    
    .message-input-area {
        padding: 16px 24px;
    }
}

/* ============================================ */
/* DARK MODE (Default sudah dark)             */
/* ============================================ */
@media (prefers-color-scheme: light) {
    /* Optional: Tambahkan light mode jika diinginkan */
    /* Untuk aplikasi rahasia, dark mode lebih baik */
}

/* Print styles - hide all for privacy */
@media print {
    body * {
        display: none !important;
    }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}