/**
 * RAPIDLAUNCH SITE MANAGER - APPLE-STYLE DESIGN
 */

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

:root {
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f5f7;
    --bg-hover: #f0f0f2;
    
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #8a8a8e;
    --text-link: #0066cc;
    
    --accent: #17617a;
    --accent-hover: #115566;
    --accent-light: rgba(23, 97, 122, 0.1);
    
    --success: #34c759;
    --success-light: rgba(52, 199, 89, 0.1);
    --warning: #ff9500;
    --warning-light: rgba(255, 149, 0, 0.1);
    --error: #ff3b30;
    --error-light: rgba(255, 59, 48, 0.1);
    --info: #007aff;
    --info-light: rgba(0, 122, 255, 0.1);
    
    --border: #e5e5e7;
    --border-hover: #d1d1d6;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', Monaco, Consolas, monospace;
    
    --sidebar-width: 260px;
    
    --transition: all 0.2s ease;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.site-layout { display: flex; min-height: 100vh; }

.site-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 18px;
    font-weight: 700;
}
.sidebar-logo:hover { color: var(--text-primary); }

.sidebar-logo img { height: 40px; width: auto; }

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.nav-section { margin-bottom: 24px; }

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item { margin-bottom: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-light);
    color: var(--accent);
}

.nav-link svg { width: 20px; height: 20px; flex-shrink: 0; }

.nav-badge {
    margin-left: auto;
    background: var(--error);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--border); }

.site-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    background: var(--bg-primary);
    min-height: 100vh;
}

.site-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-search {
    position: relative;
    width: 320px;
}

.header-search input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

.header-search input::placeholder { color: var(--text-muted); }
.header-search input:focus { outline: none; border-color: var(--accent); background: var(--bg-secondary); }

.header-search svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.header-actions { display: flex; align-items: center; gap: 12px; }

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

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

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px 6px 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.user-name { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.user-role { font-size: 12px; color: var(--text-muted); }

.site-content { padding: 24px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--space-xl); }
.page-title { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; }
.page-header-left h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }

.back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); text-decoration: none; font-size: 14px; margin-bottom: 16px; }
.back-link:hover { color: var(--accent-hover); }

.card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg-tertiary); }
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 20px; }
.card-body-no-padding { padding: 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.form-group { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px 14px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 14px; color: var(--text-primary); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px 16px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); font-size: 14px; color: var(--text-primary); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }
.form-group small, .form-hint { font-size: 12px; color: var(--text-muted); }

.success-message, .error-message { padding: 12px 16px; border-radius: var(--radius-lg); margin-bottom: 20px; font-size: 14px; }
.success-message { background: var(--success-light); color: var(--success); border: 1px solid rgba(52, 199, 89, 0.2); }
.error-message { background: var(--error-light); color: var(--error); border: 1px solid rgba(255, 59, 48, 0.2); }

.filters-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-xl); }
.filter-tabs { display: flex; gap: var(--space-xs); background: var(--bg-secondary); padding: 4px; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.filter-tab { padding: var(--space-sm) var(--space-md); border-radius: var(--radius-md); font-size: var(--text-sm, 13px); color: var(--text-muted); text-decoration: none; transition: var(--transition); }
.filter-tab:hover { color: var(--text-primary); }
.filter-tab.active { background: var(--accent); color: white; }
.search-form { display: flex; gap: var(--space-sm); }
.search-form input { padding: var(--space-sm) var(--space-md); border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 250px; background: var(--bg-secondary); color: var(--text-primary); }

.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-md); color: var(--text-muted); transition: var(--transition); }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

.clients-table { display: flex; flex-direction: column; gap: 0; }
.table-header, .table-row { display: grid; grid-template-columns: 2fr 2fr 1fr 1fr 1fr 60px; gap: 16px; padding: 12px 16px; align-items: center; }
.table-header { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; background: var(--bg-tertiary); border-radius: var(--radius-lg) var(--radius-lg) 0 0; border: 1px solid var(--border); border-bottom: none; }
.table-row { border: 1px solid var(--border); border-top: none; transition: var(--transition); }
.table-row:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.table-row:hover { background: var(--bg-hover); }
.table-row small { display: block; font-size: 12px; color: var(--text-muted); }
.status-badge, .plan-badge { display: inline-block; padding: 4px 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; }
.status-badge.live, .plan-badge.core { background: var(--success-light); color: var(--success); }
.status-badge.building { background: var(--warning-light); color: var(--warning); }
.status-badge.inquiry { background: var(--info-light); color: var(--info); }
.status-badge.proposal { background: var(--accent-light); color: var(--accent); }
.status-badge.review { background: #fef3c7; color: #d97706; }
.status-badge.archived { background: #f1f5f9; color: #64748b; }
.status-badge.lead { background: var(--warning-light); color: var(--warning); }
.status-badge.suspended { background: var(--error-light); color: var(--error); }
.status-badge.churned { background: #f1f5f9; color: #64748b; }
.plan-badge.max { background: var(--info-light); color: var(--info); }
.plan-badge.maxpro { background: var(--accent-light); color: var(--accent); }
.ticket-count { background: var(--error-light); color: var(--error); padding: 2px 8px; border-radius: var(--radius-full); font-size: 11px; font-weight: 600; margin-left: 4px; }

.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.info-item { display: flex; flex-direction: column; gap: 4px; }
.info-label { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }
.info-value { font-size: 14px; color: var(--text-primary); }

.deployment-list { display: flex; flex-direction: column; gap: 12px; }
.deployment-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: var(--bg-tertiary); border-radius: var(--radius-lg); }
.deployment-info { display: flex; flex-direction: column; gap: 4px; }
.deployment-action { font-weight: 600; text-transform: capitalize; }
.deployment-time { font-size: 12px; color: var(--text-muted); }
.deployment-status { padding: 4px 12px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; }
.deployment-status.success { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.deployment-status.failed { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.deployment-status.pending, .deployment-status.in_progress { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.action-buttons { display: flex; gap: 12px; flex-wrap: wrap; }

.credential-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.credential-row:last-child { border-bottom: none; }
.credential-item { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.credential-item:last-child { border-bottom: none; }
.credential-label { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.credential-value { font-size: 14px; color: var(--text-secondary); font-family: var(--font-mono, monospace); }
.credential-value.copyable { cursor: pointer; }
.credential-value.copyable:hover { color: var(--accent); }

.site-domain { color: var(--text-muted); font-size: 14px; }

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .table-header, .table-row { grid-template-columns: 1fr 1fr; font-size: 13px; }
    .filters-bar { flex-direction: column; gap: var(--space-md); }
    .search-form { width: 100%; }
    .search-form input { min-width: 0; width: 100%; }
    .filter-tabs { width: 100%; overflow-x: auto; }
    .info-grid { grid-template-columns: 1fr; }
    .action-buttons { flex-direction: column; }
    .page-header { flex-direction: column; gap: 12px; }
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 12px 20px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; background: var(--bg-tertiary); border-bottom: 1px solid var(--border); }
.data-table td { padding: 14px 20px; font-size: 14px; color: var(--text-secondary); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--bg-hover); }

.badge { display: inline-flex; padding: 4px 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-error { background: var(--error-light); color: var(--error); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-primary { background: var(--accent-light); color: var(--accent); }
.badge-live { background: var(--success-light); color: var(--success); }
.badge-building { background: var(--warning-light); color: var(--warning); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; border: none; transition: var(--transition); }
.btn-primary { background: var(--accent); color: white; box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }



.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 28px; }

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon { width: 44px; height: 44px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon-primary { background: var(--accent-light); color: var(--accent); }
.stat-icon-success { background: var(--success-light); color: var(--success); }
.stat-icon-warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.sites { background: var(--accent-light); color: var(--accent); }
.stat-icon.live { background: var(--success-light); color: var(--success); }
.stat-icon.health { background: var(--warning-light); color: var(--warning); }
.stat-icon.magic { background: var(--info-light); color: var(--info); }

.stat-content { flex: 1; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.dashboard-header { margin-bottom: 24px; }
.dashboard-header h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.dashboard-header p { color: var(--text-muted); font-size: 14px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }

.dashboard-section { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }

.section-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.section-header h2 { font-size: 15px; font-weight: 600; color: var(--text-primary); }

.view-all { font-size: 14px; font-weight: 600; color: var(--accent); text-decoration: none; }
.view-all:hover { color: var(--accent-hover); }

.site-list { display: flex; flex-direction: column; }

.site-item { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); transition: var(--transition); text-decoration: none; color: inherit; }
.site-item:last-child { border-bottom: none; }
.site-item:hover { background: var(--bg-hover); }

.site-info { flex: 1; }
.site-info h3 { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.site-info p { font-size: 13px; color: var(--text-muted); }

.sites-table { background: var(--bg-secondary); border-radius: var(--radius-lg); overflow: hidden; }

.header-left { display: flex; flex-direction: column; gap: 4px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.user-info { display: flex; flex-direction: column; gap: 2px; }

.entity-info { display: flex; align-items: center; gap: 12px; }
.entity-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; background: var(--accent-light); color: var(--accent); }
.entity-primary { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.entity-secondary { font-size: 12px; color: var(--text-muted); }

.empty-state { padding: 48px 24px; text-align: center; color: var(--text-muted); }
.empty-state svg { width: 56px; height: 56px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }

a { color: var(--text-link); text-decoration: none; }
a:hover { color: #004499; }

.alert { padding: 14px 16px; border-radius: var(--radius-md); font-size: 14px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.alert-success { background: var(--success-light); color: var(--success); }
.alert-error { background: var(--error-light); color: var(--error); }

.grid { display: grid; gap: var(--space-lg); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

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

.filter-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

.menu-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

.menu-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-decoration: none;
    transition: var(--transition);
    display: block;
    box-shadow: var(--shadow-sm);
}

.menu-box:hover { background: var(--bg-hover); border-color: var(--accent); transform: translateY(-3px); }

.menu-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--accent);
    margin-bottom: 12px;
}

.menu-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.menu-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.menu-count { font-size: 12px; color: var(--accent); font-weight: 600; }

.actions { display: flex; gap: 8px; }

@media (max-width: 1024px) {
    .site-sidebar { transform: translateX(-100%); transition: var(--transition); }
    .site-sidebar.open { transform: translateX(0); }
    .site-main { margin-left: 0; }
    .grid-cols-2, .grid-cols-3 { grid-template-columns: 1fr; }
    .header-search { width: 200px; }
}

@media (max-width: 768px) {
    .site-content { padding: 16px; }
    .page-title { font-size: 22px; }
    .stats-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.login-logo svg { width: 48px; height: 48px; }
.login-logo span { font-size: 20px; font-weight: 700; color: var(--text-primary); }

.login-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
}
/* Utility classes for inline style replacement */
.info-value-sm { font-size: 12px; color: var(--text-primary); }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.text-muted { color: var(--text-muted); }
.fs-14 { font-size: 14px; }
.btn-block { width: 100%; }
.svg-fallback { display: none; }
.notif-btn { position: relative; }
.sync-db-label { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; }
.empty-deployments { color: var(--text-muted); text-align: center; padding: 24px; }
