/* ==========================================================================
   The Owlish Mind - Clean Modern Admin Stylesheet
   ========================================================================== */

:root {
    --primary: #3092b7;
    --primary-dark: #227393;
    --primary-light: #e6f6fb;
    --primary-border: #bee3f2;
    --accent: #1e293b;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --border-color-subtle: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --success: #10b981;
    --success-light: #ecfdf5;
    --success-border: #a7f3d0;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --danger-border: #fecaca;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --info: #0284c7;
    --info-light: #f0f9ff;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

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

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

/* ==========================================================================
   Navigation Bar
   ========================================================================== */

.admin-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

.admin-nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.admin-brand img {
    height: 42px;
    width: auto;
    object-fit: contain;
}

.admin-brand-text {
    display: flex;
    flex-direction: column;
}

.admin-brand-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.admin-brand-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
}

.admin-nav-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.btn-nav-outline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    background: #ffffff;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.btn-nav-outline:hover {
    color: var(--text-main);
    background: var(--bg-page);
    border-color: #cbd5e1;
}

.btn-logout {
    color: var(--danger);
    border-color: var(--danger-border);
    background: var(--danger-light);
}

.btn-logout:hover {
    color: #b91c1c;
    background: #fee2e2;
    border-color: #fca5a5;
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */

.admin-wrapper {
    max-width: 1400px;
    margin: 1.75rem auto 3rem;
    padding: 0 1.5rem;
}

.admin-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-page-title {
    font-size: 1.625rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.03em;
}

.admin-page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ==========================================================================
   KPI Summary Stats
   ========================================================================== */

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

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

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

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.info    { background: var(--info-light); color: var(--info); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
    margin: 0.2rem 0;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* ==========================================================================
   Tabs Component
   ========================================================================== */

.tabs-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: var(--transition);
}

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

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
    color: var(--text-main);
    font-size: 0.725rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    min-width: 20px;
}

.tab-btn.active .tab-count {
    background: var(--primary-light);
    color: var(--primary);
}

/* ==========================================================================
   Card & Data Table
   ========================================================================== */

.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-toolbar {
    padding: 1.15rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
}

.search-input-group {
    position: relative;
    max-width: 360px;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.95rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.55rem 0.85rem 0.55rem 2.35rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-page);
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}

.search-input:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(48, 146, 183, 0.15);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--primary);
    color: #ffffff;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: #ffffff;
    color: var(--text-main);
    padding: 0.55rem 0.95rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.btn-outline:hover {
    background: var(--bg-page);
    border-color: #cbd5e1;
}

/* Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.custom-table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.775rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.custom-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color-subtle);
    color: var(--text-main);
    vertical-align: middle;
}

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

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

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

/* Badges */
.badge-service {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid var(--primary-border);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-date {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-main);
}

.contact-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.8rem;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
}

.contact-link:hover {
    color: var(--primary);
}

.message-preview {
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-muted);
}

/* Action Buttons */
.action-group {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:hover {
    background: var(--bg-page);
    color: var(--text-main);
}

.btn-action.btn-view:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary);
}

.btn-action.btn-delete:hover {
    background: var(--danger-light);
    border-color: var(--danger-border);
    color: var(--danger);
}

/* Empty State */
.empty-state {
    padding: 3.5rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

/* ==========================================================================
   Alerts & Notifications
   ========================================================================= */

.alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: var(--success-light);
    color: #065f46;
    border: 1px solid var(--success-border);
}

.alert-danger {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid var(--danger-border);
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ==========================================================================
   Modal Dialog
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

.modal-backdrop.show {
    display: flex;
}

.modal-box {
    background: #ffffff;
    width: 100%;
    max-width: 580px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: modalSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 1.15rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

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

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

.modal-close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-row {
    margin-bottom: 1rem;
}

.modal-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.modal-content-text {
    font-size: 0.925rem;
    color: var(--text-main);
    background: var(--bg-page);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    white-space: pre-wrap;
    word-break: break-word;
}

.modal-footer {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-top: 1px solid var(--border-color);
    background: #f8fafc;
}

/* ==========================================================================
   Authentication Pages (Login / Register)
   ========================================================================== */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: #f1f5f9;
}

.auth-card {
    background: #ffffff;
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 2.25rem;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-brand img {
    height: 52px;
    width: auto;
    object-fit: contain;
    margin-bottom: 0.75rem;
}

.auth-brand h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.auth-brand p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

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

.input-wrapper {
    position: relative;
}

.form-control {
    width: 100%;
    padding: 0.7rem 0.9rem;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    background: #ffffff;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(48, 146, 183, 0.15);
}

.btn-toggle-pwd {
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-toggle-pwd:hover {
    color: var(--text-main);
}

.btn-auth-submit {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 0.5rem;
}

.btn-auth-submit:hover {
    background: var(--primary-dark);
}

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.auth-hint {
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    font-size: 0.8rem;
    color: var(--primary-dark);
    margin-top: 1rem;
    text-align: left;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .admin-navbar {
        padding: 0.75rem 1rem;
    }
    
    .admin-brand-title {
        font-size: 1rem;
    }

    .admin-wrapper {
        padding: 0 1rem;
        margin-top: 1.25rem;
    }

    .user-pill span {
        display: none;
    }

    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

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

    .toolbar-actions {
        justify-content: flex-end;
    }

    .custom-table th,
    .custom-table td {
        padding: 0.75rem 0.85rem;
    }
}
