/* ==========================================================================
   PaisaPing Design System & Global Stylesheet
   Modern Glassmorphism, Vibrant Emerald/Green Accents, Sleek Dark-Light Balance
   ========================================================================== */

:root {
    --primary: #10b981;
    --primary-hover: #059669;
    --primary-light: #ecfdf5;
    --primary-glow: rgba(16, 185, 129, 0.25);
    
    --dark: #0f172a;
    --dark-surface: #1e293b;
    --dark-border: #334155;
    
    --bg-page: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px -2px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 24px -4px rgba(0,0,0,0.12);
    --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.35);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Layout & Sidebar
   ========================================================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: #0b1329;
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.logo-text .name {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: block;
}

.logo-text .badge {
    font-size: 0.68rem;
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.sidebar-wallet {
    margin: 16px 14px;
    padding: 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
}

.wallet-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.wallet-balance {
    font-size: 1.5rem;
    font-weight: 800;
    color: #34d399;
    margin: 4px 0 10px 0;
    font-family: 'JetBrains Mono', monospace;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    color: white;
    background: rgba(255,255,255,0.06);
}

.nav-item.active {
    color: white;
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.25) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-left: 3px solid #10b981;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.avatar {
    width: 34px;
    height: 34px;
    background: #3b82f6;
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-info .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .user-email {
    font-size: 0.72rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    color: #94a3b8;
    text-decoration: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-logout:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* ==========================================================================
   Main Content & Topbar
   ========================================================================== */
.main-content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 70px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.meta-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.meta-status.status-online {
    background: #ecfdf5;
    color: #065f46;
}

.meta-status.status-warning {
    background: #fffbeb;
    color: #92400e;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: currentColor;
}

.content-body {
    padding: 32px;
    flex: 1;
}

/* ==========================================================================
   Cards, Grid & Stats
   ========================================================================== */
.grid {
    display: grid;
    gap: 20px;
}

.grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pipeline-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.pipeline-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }

.stat-content .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-content .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 14px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-outline-success {
    background: transparent;
    border-color: #10b981;
    color: #10b981;
    width: 100%;
}

.btn-outline-success:hover {
    background: #10b981;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-main);
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ==========================================================================
   Tables & Badges
   ========================================================================== */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    padding: 12px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.table td {
    padding: 14px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
}

.table tr:hover td {
    background: #f8fafc;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ==========================================================================
   2-Way Live Chat Interface
   ========================================================================== */
.chat-container, .inbox-container {
    display: flex;
    height: calc(100vh - 140px);
    min-height: 580px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.chat-sidebar {
    width: 320px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-threads-list {
    flex: 1;
    overflow-y: auto;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    background: #f8fafc;
    color: var(--text-muted);
}

.chat-thread-item {
    padding: 14px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-thread-item:hover, .chat-thread-item.active {
    background: #f1f5f9;
}

.chat-thread-item.active {
    border-left: 3px solid var(--primary);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #efeae2;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
}

.chat-header {
    min-height: 64px;
    height: auto;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    gap: 12px;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg-bubble {
    max-width: 65%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.msg-bubble.inbound {
    align-self: flex-start;
    background: white;
    border-top-left-radius: 2px;
}

.msg-bubble.outbound {
    align-self: flex-end;
    background: #d9fdd3;
    border-top-right-radius: 2px;
}

.msg-time {
    font-size: 0.68rem;
    color: #64748b;
    margin-top: 4px;
    text-align: right;
}

.chat-input-bar {
    padding: 14px 20px;
    background: #f0f2f5;
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ==========================================================================
   Template Live Preview Phone Mockup
   ========================================================================== */
.template-builder-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 32px;
}

.phone-mockup {
    background: #111827;
    border: 8px solid #374151;
    border-radius: 36px;
    padding: 16px;
    width: 320px;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
}

.phone-screen {
    background: #efeae2;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    border-radius: 24px;
    min-height: 480px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.preview-bubble {
    background: white;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.preview-header {
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.preview-body {
    font-size: 0.88rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

.preview-footer {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 8px;
}
