/* ============================================
   Call Insights Licensing Server
   RMC Solutions Branding
   ============================================ */

:root {
    --primary: #36749D;
    --primary-light: #4a8ab5;
    --primary-dark: #2a5d80;
    --secondary: #3A4856;
    --secondary-light: #4d5e6f;
    --accent-1: #9DADBC;
    --accent-2: #975D7A;
    --accent-3: #BBA5B0;
    --success: #28a745;
    --success-bg: #e8f5ec;
    --warning: #e8a317;
    --warning-bg: #fef8e7;
    --danger: #dc3545;
    --danger-bg: #fbe9eb;
    --info: #36749D;
    --info-bg: #eaf1f6;
    --bg: #f3f5f7;
    --bg-white: #ffffff;
    --text: #2c3340;
    --text-light: #5a6677;
    --text-muted: #8d97a5;
    --border: #d6dce4;
    --border-light: #e8ecf1;
    --sidebar-bg: #2c3644;
    --sidebar-hover: #344050;
    --sidebar-text: #a8b4c2;
    --sidebar-active: #36749D;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(44, 54, 68, 0.06);
    --shadow: 0 2px 8px rgba(44, 54, 68, 0.08);
    --shadow-md: 0 4px 12px rgba(44, 54, 68, 0.10);
    --shadow-lg: 0 8px 24px rgba(44, 54, 68, 0.14);
    --transition: 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ================================================================
   LAYOUT
   ================================================================ */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: 256px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(54, 116, 157, 0.4);
}

.logo-icon.large {
    width: 64px;
    height: 64px;
    font-size: 32px;
    border-radius: 16px;
}

.logo-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.2px;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--accent-2);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
    margin-top: 2px;
}

.nav-menu {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}

.nav-menu li { margin: 1px 0; }

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    letter-spacing: 0.1px;
}

.nav-menu a .nav-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-menu a:hover {
    background: var(--sidebar-hover);
    color: #e4e9ef;
}

.nav-menu a.active {
    background: rgba(54, 116, 157, 0.15);
    color: #ffffff;
    border-left-color: var(--primary);
    font-weight: 600;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--sidebar-text);
}

.user-info .user-avatar {
    width: 28px;
    height: 28px;
    background: var(--accent-2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
    font-weight: 600;
}

.logout-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all var(--transition);
}

.logout-link:hover {
    color: var(--danger);
    background: rgba(220, 53, 69, 0.1);
}

.user-name-link {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    transition: color var(--transition);
}

.user-name-link:hover {
    color: #ffffff;
}

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

.page-header {
    background: var(--bg-white);
    padding: 22px 32px;
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--secondary);
    letter-spacing: -0.3px;
}

.content {
    padding: 24px 32px;
    flex: 1;
}

/* ================================================================
   COMPONENTS
   ================================================================ */

/* ---- Cards ---- */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.card-narrow { max-width: 640px; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
}

.card-header h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-body {
    padding: 24px;
}

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

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.stat-card:nth-child(2)::before { background: var(--accent-2); }
.stat-card:nth-child(3)::before { background: var(--success); }

.stat-card-inline { text-align: left; }
.stat-card-inline::before { display: none; }

.stat-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--secondary);
    line-height: 1.1;
    letter-spacing: -1px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ---- Grid ---- */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1100px) {
    .grid-2col { grid-template-columns: 1fr; }
}

/* ---- Tables ---- */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 13.5px;
}

.table th {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    background: var(--bg);
    position: sticky;
    top: 0;
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: rgba(54, 116, 157, 0.03);
}

.table td a {
    color: var(--primary);
    font-weight: 600;
}

.table td a:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

.row-inactive { opacity: 0.45; }
.row-inactive:hover { opacity: 0.7; }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: var(--bg);
    color: var(--text-muted);
    white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: #96700d; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    line-height: 1.4;
    white-space: nowrap;
    font-family: inherit;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-secondary { background: var(--bg-white); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--text-muted); color: var(--text); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #229a3c; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #d49615; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c82333; color: #fff; }

.btn-full { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-sm:hover { transform: none; box-shadow: none; }

.btn-group-small { display: flex; gap: 4px; }

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

.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-white);
    transition: all var(--transition);
}

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

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(54, 116, 157, 0.12);
}

.form-group input:disabled {
    background: var(--bg);
    color: var(--text-light);
    cursor: not-allowed;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-inline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    align-items: end;
}

.inline-form { display: inline-block; }

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-weight: 500 !important;
}

.checkbox-label input[type="checkbox"] {
    width: 18px !important;
    height: 18px;
    accent-color: var(--primary);
}

/* ---- Alerts ---- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 18px;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
}

.alert strong { font-weight: 700; }

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.alert-success {
    background: var(--success-bg);
    color: #1e7e34;
    border: 1px solid rgba(40, 167, 69, 0.2);
}

.alert-warning {
    background: var(--warning-bg);
    color: #785b0e;
    border: 1px solid rgba(232, 163, 23, 0.25);
}

/* ---- API Key Display ---- */
.api-key-display {
    margin-top: 20px;
    padding: 20px;
    background: var(--sidebar-bg);
    border-radius: var(--radius-lg);
    color: #fff;
}

.api-key-display label {
    font-size: 11px;
    color: var(--accent-1);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    display: block;
    font-weight: 700;
}

.key-container {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(0,0,0,0.2);
    padding: 12px 16px;
    border-radius: var(--radius);
}

.key-container code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 13px;
    word-break: break-all;
    flex: 1;
    color: var(--accent-3);
}

.key-container .btn { flex-shrink: 0; }

/* ---- Instance Info ---- */
.instance-info { padding: 16px 0; }
.instance-info p { margin-bottom: 6px; font-size: 14px; }

/* ---- Detail List ---- */
.detail-list {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 20px;
    align-items: baseline;
}

.detail-list dt {
    font-weight: 700;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.detail-list dd {
    font-size: 14px;
    color: var(--text);
}

/* ---- Code Block ---- */
.code-block {
    background: var(--sidebar-bg);
    color: var(--accent-1);
    padding: 14px 18px;
    border-radius: var(--radius);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 12.5px;
    overflow-x: auto;
    line-height: 1.6;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    margin-top: 24px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---- Page Actions ---- */
.page-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

/* ---- Chart ---- */
.chart-container {
    position: relative;
    height: 250px;
}

/* ================================================================
   UTILITY CLASSES
   ================================================================ */
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.text-mono { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; }
.text-small { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 24px 0;
}

h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 16px;
}

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 80%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(54, 116, 157, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 60%;
    height: 150%;
    background: radial-gradient(ellipse, rgba(151, 93, 122, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.login-container {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 48px 40px;
    width: 420px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-header .logo-icon {
    margin: 0 auto 16px;
}

.login-header h1 {
    font-size: 22px;
    color: var(--secondary);
    margin-top: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.login-subtitle {
    font-size: 11px;
    color: var(--accent-2);
    text-transform: uppercase;
    letter-spacing: 2.5px;
    margin-top: 6px;
    font-weight: 700;
}

.login-form { margin-top: 8px; }

.login-form .form-group { margin-bottom: 20px; }

.login-form .btn-primary {
    padding: 12px 18px;
    font-size: 14.5px;
    margin-top: 8px;
}

.login-footer {
    text-align: center;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.login-footer p {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; }
    .content { padding: 20px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-inline-grid { grid-template-columns: 1fr; }
    .login-container { width: 90%; padding: 32px 24px; }
}
