/**
 * MexAutomate Admin Styles
 * Copyright (c) MexTech Limited (https://mextechltd.name.ng)
 * Mobile-first responsive design
 */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --bg-color: #f1f5f9;
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --header-height: 60px;
    --sidebar-width: 260px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

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

a:hover {
    text-decoration: underline;
}

/* Admin Wrapper */
.admin-wrapper {
    min-height: 100vh;
}

/* Header */
.admin-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.header-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-logout {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logout:hover {
    background: rgba(255,255,255,0.1);
    text-decoration: none;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1001;
}

.sidebar-overlay.active {
    display: block;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1002;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
}

.sidebar-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.sidebar-close:hover {
    background: rgba(255,255,255,0.1);
}

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

.nav-menu li {
    margin: 0;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--sidebar-text);
    transition: all 0.2s;
    font-size: 0.95rem;
}

.nav-menu a:hover {
    background-color: rgba(255,255,255,0.1);
    text-decoration: none;
}

.nav-menu a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-menu li.active a {
    background-color: var(--primary-color);
    color: white;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    font-size: 0.875rem;
    color: var(--sidebar-text);
    word-break: break-word;
}

.user-info i {
    font-size: 1.25rem;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.btn-logout:hover {
    background: rgba(255,255,255,0.2);
}

/* Main Content */
.main-content {
    padding: 80px 15px 30px;
    min-height: 100vh;
}

/* Page Header */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Dashboard */
.dashboard h1 {
    font-size: 1.5rem;
    margin-bottom: 25px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.widgets {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
}

.stat-icon.bots {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
}

.stat-icon.messages {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.stat-icon.sessions {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.stat-content {
    min-width: 0;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dashboard Sections */
.dashboard-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Sections */
.section, .dashboard-sections .section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.section h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
}

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

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

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-info {
    background-color: var(--info-color);
    color: white;
}

.btn-info:hover {
    background-color: #0891b2;
}

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

.btn-block {
    display: flex;
    width: 100%;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.875rem;
}

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

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.data-table th, .data-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: #f8fafc;
}

.data-table .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.info-table {
    width: 100%;
}

.info-table td {
    padding: 10px 0;
    font-size: 0.9rem;
}

.info-table td:first-child {
    font-weight: 500;
    width: 140px;
    color: var(--text-muted);
}

/* Responsive Table Wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

/* Mobile Table Styles */
@media (max-width: 767px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
        display: block;
    }
    
    .data-table {
        min-width: 600px;
        font-size: 0.8rem;
    }
    
    .data-table th {
        padding: 10px 8px;
        font-size: 0.65rem;
        white-space: nowrap;
    }
    
    .data-table td {
        padding: 10px 8px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    .data-table .actions {
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 100px;
    }
    
    .data-table .actions .btn {
        padding: 6px 8px;
        font-size: 0.65rem;
        white-space: nowrap;
    }
}

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-secondary {
    background-color: #e2e8f0;
    color: #475569;
}

.badge-primary {
    background-color: #dbeafe;
    color: #1e40af;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}

.modal-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 5px;
}

.modal-body {
    padding: 20px;
}

.modal-content form {
    padding: 20px;
}

/* Code blocks */
code {
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    word-break: break-all;
}

.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.code-block code {
    background: transparent;
    color: #a5f3fc;
    padding: 0;
    word-break: break-all;
    font-size: 0.8rem;
}

.code-block .btn {
    align-self: flex-start;
}

/* Info box */
.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 20px;
}

.info-box h3 {
    margin-bottom: 12px;
    color: #1e40af;
    font-size: 1rem;
}

.info-box ol {
    margin-left: 20px;
    font-size: 0.9rem;
}

.info-box li {
    margin-bottom: 8px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    background: var(--card-bg);
    border-radius: 12px;
    font-size: 0.95rem;
}

/* Quick actions */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Text utilities */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* Footer */
.admin-footer {
    text-align: center;
    padding: 25px 15px;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: white;
    border-top: 1px solid var(--border-color);
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-box {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 30px 25px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

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

.login-header h1 {
    font-size: 1.75rem;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-footer {
    text-align: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ========================================
   TABLET STYLES (768px and up)
   ======================================== */
@media (min-width: 768px) {
    .main-content {
        padding: 90px 30px 40px;
    }

    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .page-header h1 {
        font-size: 1.75rem;
    }

    .dashboard h1 {
        font-size: 1.75rem;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.85rem;
    }

    .section h2 {
        font-size: 1.25rem;
    }

    .form-actions {
        flex-direction: row;
        justify-content: flex-end;
    }

    .action-buttons {
        flex-direction: row;
    }

    .modal {
        align-items: center;
        padding: 20px;
    }

    .modal-content {
        border-radius: 16px;
        max-width: 550px;
        animation: fadeIn 0.2s ease;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: scale(0.95);
        }
        to {
            opacity: 1;
            transform: scale(1);
        }
    }

    .code-block {
        flex-direction: row;
        align-items: center;
    }

    .code-block code {
        flex: 1;
    }

    .code-block .btn {
        align-self: center;
    }
}

/* ========================================
   DESKTOP STYLES (992px and up)
   ======================================== */
@media (min-width: 992px) {
    .admin-header {
        display: none;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .sidebar {
        position: fixed;
        left: 0;
        width: var(--sidebar-width);
        transition: none;
    }

    .sidebar-close {
        display: none;
    }

    .main-content {
        margin-left: var(--sidebar-width);
        padding: 40px;
    }

    .admin-footer {
        margin-left: var(--sidebar-width);
    }

    .page-header h1 {
        font-size: 1.875rem;
    }

    .dashboard h1 {
        font-size: 1.875rem;
        margin-bottom: 30px;
    }

    .stats-grid {
        gap: 25px;
    }

    .stat-card {
        padding: 24px;
    }

    .stat-icon {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    .dashboard-sections {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: 25px;
    }

    .settings-sections {
        max-width: 800px;
    }

    .section, .dashboard-sections .section {
        padding: 25px;
    }

    .section h2 {
        font-size: 1.25rem;
        margin-bottom: 20px;
    }

    .data-table th, .data-table td {
        padding: 15px;
        font-size: 0.9rem;
    }

    .data-table th {
        font-size: 0.75rem;
    }

    .modal-content {
        max-width: 600px;
    }
}

/* ========================================
   SMALL MOBILE STYLES (480px and under)
   ======================================== */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
        flex-direction: column;
        text-align: center;
    }
    
    .stat-content {
        text-align: center;
    }
    
    .stat-label {
        white-space: normal;
    }
    
    .section {
        padding: 15px;
    }
    
    .section h2 {
        font-size: 0.95rem;
    }
    
    .form-group label {
        font-size: 0.8rem;
    }
    
    .form-control {
        padding: 10px 12px;
        font-size: 16px;
    }
    
    .btn {
        padding: 8px 14px;
        font-size: 0.8rem;
        width: 100%;
    }
    
    .btn-sm {
        padding: 5px 10px;
        font-size: 0.7rem;
    }
    
    .data-table th, .data-table td {
        padding: 8px;
        font-size: 0.75rem;
    }
}

/* ========================================
   LARGE DESKTOP STYLES (1200px and up)
   ======================================== */
@media (min-width: 1200px) {
    .main-content {
        padding: 50px 60px;
    }

    .dashboard-sections {
        gap: 30px;
    }

    .stats-grid {
        gap: 30px;
    }
}
