/* OneCareSync Admin - Simple Professional Styles */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --warning: #ca8a04;
    --danger: #dc2626;
    --light: #f8fafc;
    --dark: #1e293b;
    --border: #e2e8f0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--dark);
    background-color: #f1f5f9;
}

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

a:hover {
    text-decoration: underline;
}

/* Layout */
body {
    min-height: 100vh;
    display: flex;
}

/* Layout for login/auth pages (no sidebar) - class-based fallback */
body.auth-page {
    display: block;
}

/* Layout for pages with sidebar - :has() for modern browsers */
@supports selector(:has(*)) {
    body:has(.login-container) {
        display: block;
    }
}

.sidebar {
    width: 240px;
    background: var(--dark);
    color: white;
    padding: 20px 0;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 15px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
    text-align: center;
}

.brand-logo {
    margin-bottom: 10px;
}

.brand-logo img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: white;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.sidebar-header .brand-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    background: white;
    padding: 8px 16px;
    border-radius: 20px;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.brand-onecare {
    color: #4D4D4D;
}

.brand-sync {
    color: #87A922;
}

.sidebar-header small {
    display: block;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    margin-top: 8px;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li a {
    display: block;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    transition: all 0.2s;
}

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

.sidebar-nav li a.active {
    border-left: 3px solid var(--primary);
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 15px 0;
}

.main-content {
    flex: 1;
    padding: 20px 30px;
    overflow-x: auto;
    margin-left: 240px;
    min-height: 100vh;
}

/* Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 15px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.page-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--dark);
}

.user-info {
    text-align: right;
    font-size: 13px;
    color: var(--secondary);
}

.user-info small {
    color: var(--secondary);
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

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

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-card .label {
    font-size: 13px;
    color: var(--secondary);
    margin-bottom: 5px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
}

.stat-card .subtext {
    font-size: 12px;
    color: var(--secondary);
    margin-top: 5px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--secondary);
}

tr:hover {
    background: #f8fafc;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: var(--success);
}

.badge-warning {
    background: #fef3c7;
    color: var(--warning);
}

.badge-danger {
    background: #fee2e2;
    color: var(--danger);
}

.badge-primary {
    background: #dbeafe;
    color: var(--primary);
}

.badge-secondary {
    background: #f1f5f9;
    color: var(--secondary);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.btn-secondary {
    background: white;
    color: var(--dark);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #f8fafc;
    text-decoration: none;
}

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

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

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 13px;
}

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

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

select.form-control {
    appearance: none;
    background: white url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background: #dcfce7;
    color: var(--success);
    border: 1px solid #86efac;
}

.alert-danger {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fca5a5;
}

.alert-warning {
    background: #fef3c7;
    color: var(--warning);
    border: 1px solid #fcd34d;
}

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

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 24px;
}

.login-box .subtitle {
    text-align: center;
    color: var(--secondary);
    margin-bottom: 30px;
}

.login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #1e293b;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.login-brand-name {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
}

.login-subtitle {
    text-align: center;
    font-size: 14px;
    color: var(--secondary);
    margin-bottom: 5px;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin-top: 20px;
}

.pagination a, .pagination span {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--dark);
}

.pagination a:hover {
    background: #f8fafc;
    text-decoration: none;
}

.pagination .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination .disabled {
    color: var(--secondary);
    cursor: not-allowed;
}

/* Search Box */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-box input {
    flex: 1;
    max-width: 300px;
}

/* Modal/Dialog */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    text-align: right;
}

/* Utility Classes */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--secondary); }
.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-1 { margin-top: 5px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 15px; }
.mt-4 { margin-top: 20px; }
.mb-1 { margin-bottom: 5px; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 15px; }
.mb-4 { margin-bottom: 20px; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-2 { gap: 10px; }

/* Grid */
.grid {
    display: grid;
    gap: 20px;
}

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

@media (max-width: 992px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Message Management Styles */
.status-connected,
.status-disconnected {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot-green {
    background: var(--success);
    box-shadow: 0 0 8px rgba(22, 163, 74, 0.5);
}

.status-dot-red {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.5);
}

.stat-card {
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--secondary);
    margin-top: 4px;
}

.stat-card-warning {
    border-left: 4px solid var(--warning);
}

.stat-card-danger {
    border-left: 4px solid var(--danger);
}

.card-header-danger {
    background: #fee2e2;
    color: var(--danger);
}

.card-header-warning {
    background: #fef3c7;
    color: var(--warning);
}

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

.btn-warning:hover {
    background: #a16207;
    text-decoration: none;
}

.py-4 {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.mx-2 {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

/* Sidebar Submenu */
.sidebar-nav .has-submenu > a {
    position: relative;
}

.sidebar-nav .has-submenu > a::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(255,255,255,0.5);
    transition: transform 0.2s;
}

.sidebar-nav .has-submenu.submenu-open > a::after {
    transform: translateY(-50%) rotate(180deg);
}

.sidebar-nav .submenu {
    list-style: none;
    background: rgba(0,0,0,0.2);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.sidebar-nav .submenu.show {
    max-height: 300px;
}

.sidebar-nav .submenu li a {
    padding: 10px 20px 10px 35px;
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    display: block;
}

.sidebar-nav .submenu li a:hover {
    background: rgba(255,255,255,0.05);
    color: white;
    text-decoration: none;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--dark);
    color: white;
    border: none;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    margin: 5px 0;
    transition: 0.3s;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

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

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

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        display: block;
    }

    .menu-toggle {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100vh;
        width: 260px;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        padding: 70px 12px 20px;
        margin-left: 0;
        width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 15px;
    }

    .page-header h2 {
        font-size: 18px;
    }

    .user-info {
        text-align: left;
        font-size: 12px;
    }

    .grid-4, .grid-3, .grid-2 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card .value,
    .stat-value {
        font-size: 1.5rem;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 500px;
    }

    th, td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .card {
        margin-bottom: 15px;
    }

    .card-header {
        padding: 12px 15px;
        font-size: 14px;
    }

    .card-body {
        padding: 15px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .btn-sm {
        padding: 5px 8px;
        font-size: 11px;
    }

    .btn-group {
        flex-wrap: wrap;
    }

    .form-control {
        padding: 10px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .search-box {
        flex-direction: column;
    }

    .search-box input {
        max-width: 100%;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 3px;
    }

    .pagination a, .pagination span {
        padding: 6px 10px;
        font-size: 13px;
    }

    .alert {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Login page mobile */
    .login-box {
        padding: 25px 20px;
        margin: 15px;
        max-width: none;
    }

    .login-logo img {
        width: 60px;
        height: 60px;
    }

    .login-brand-name {
        font-size: 20px;
    }

    /* Filter tabs mobile */
    .filter-tabs {
        flex-wrap: wrap;
        gap: 8px;
    }

    .filter-tab {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* Detail grids mobile */
    .detail-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    /* Action buttons mobile */
    .action-buttons {
        flex-direction: column !important;
    }

    /* Hide less important table columns on mobile */
    .hide-mobile {
        display: none;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .main-content {
        padding: 65px 10px 15px;
    }

    .page-header {
        padding: 10px 12px;
    }

    .page-header h2 {
        font-size: 16px;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-card .value,
    .stat-value {
        font-size: 1.25rem;
    }

    table {
        min-width: 400px;
    }

    th, td {
        padding: 8px 10px;
        font-size: 12px;
    }

    .btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .badge {
        padding: 2px 6px;
        font-size: 11px;
    }
}

/* Tablet landscape */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }

    .main-content {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
