/* =============================================
   CRM Agente Autorizado - Quick ISP
   Visual Identity: quick.com.br
   ============================================= */

/* --- CSS Variables --- */
:root {
    --primary: #00B859;
    --primary-dark: #00994A;
    --secondary: #1A2744;
    --bg: #F5F7FA;
    --card-bg: #ffffff;
    --text: #1A2744;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --danger: #EF4444;
    --warning: #F59E0B;
    --success: #10B981;
    --info: #3B82F6;
    --sidebar-width: 260px;
    --sidebar-bg: #1A2744;
    --sidebar-text: #CBD5E1;
}

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

/* --- Body Styling --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

img {
    max-width: 100%;
    height: auto;
}

/* --- Layout Wrapper --- */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 40;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* --- Sidebar Header --- */
.sidebar-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 64px;
}

.sidebar-header img {
    max-height: 48px;
    height: 40px;
    object-fit: contain;
}

/* --- Sidebar Navigation --- */
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* --- Sidebar Link --- */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    margin-bottom: 2px;
    white-space: nowrap;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--primary);
    color: #ffffff;
    font-weight: 600;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* --- Sidebar Section --- */
.sidebar-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94A3B8;
    padding: 16px 16px 8px;
    font-weight: 600;
}

/* --- Sidebar Footer --- */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- Sidebar User --- */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 500;
}

.sidebar-user-role {
    font-size: 11px;
    color: #94A3B8;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Top Bar --- */
.top-bar {
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.top-bar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-bar-time {
    font-size: 13px;
    color: var(--text-muted);
}

/* --- Buttons --- */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.5;
}

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

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

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

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

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

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

.btn-icon {
    padding: 6px;
    border-radius: 6px;
}

/* --- Page Content --- */
.page-content {
    flex: 1;
    padding: 24px;
}

/* --- Greeting --- */
.greeting {
    margin-bottom: 24px;
}

.greeting h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.greeting p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

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

/* --- Stat Card --- */
.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border-left: 4px solid;
}

.stat-card.primary {
    border-color: var(--primary);
}

.stat-card.warning {
    border-color: var(--warning);
}

.stat-card.success {
    border-color: var(--success);
}

.stat-card.info {
    border-color: var(--info);
}

.stat-card.danger {
    border-color: var(--danger);
}

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

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-top: 4px;
}

/* --- Card --- */
.card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

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

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

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    background: #F9FAFB;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

tr:hover td {
    background: #F9FAFB;
}

/* --- Badge --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success {
    background: #D1FAE5;
    color: #065F46;
}

.badge-warning {
    background: #FEF3C7;
    color: #92400E;
}

.badge-danger {
    background: #FEE2E2;
    color: #991B1B;
}

.badge-info {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-secondary {
    background: #F3F4F6;
    color: #4B5563;
}

.badge-primary {
    background: #D1FAE5;
    color: #065F46;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal::-webkit-scrollbar {
    width: 6px;
}

.modal::-webkit-scrollbar-track {
    background: transparent;
}

.modal::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 4px;
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

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

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text);
    background: #ffffff;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 184, 89, 0.1);
}

.form-input::placeholder {
    color: #9CA3AF;
}

.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text);
    background: #ffffff;
    appearance: auto;
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 184, 89, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* --- Empty State --- */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 14px;
}

/* --- Actions Cell --- */
.actions-cell {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* --- Notification Badge --- */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: #ffffff;
    font-size: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* --- Hamburger Button --- */
.hamburger {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
}

.hamburger svg {
    width: 24px;
    height: 24px;
    stroke: var(--text);
}

/* --- Sidebar Overlay --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 35;
}

/* --- Toast Notifications --- */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    z-index: 100;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* --- Utility Classes --- */
.text-right {
    text-align: right;
}

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

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

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

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

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

.font-bold {
    font-weight: 700;
}

.mt-4 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

.gap-2 {
    gap: 8px;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

/* --- Import Section --- */
.import-section {
    margin-top: 16px;
    padding: 16px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    text-align: center;
}

.import-section p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.import-input {
    display: none;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

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

/* --- Stats Row (flex alternative to grid) --- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* --- Text Secondary --- */
.text-secondary {
    color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .main-content {
        margin-left: 0;
    }

    .hamburger {
        display: block;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .top-bar-time {
        display: none;
    }

    .page-content {
        padding: 16px;
    }

    .top-bar {
        padding: 0 16px;
    }

    .modal {
        max-width: 100%;
        margin: 0 8px;
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .stat-value {
        font-size: 22px;
    }

    .greeting h1 {
        font-size: 20px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}
