:root {
    --sidebar-width: 250px;
    --primary: #25D366;
    --primary-dark: #1ebe5d;
    --dark: #1e293b;
    --dark-light: #334155;
    --gray: #64748b;
    --gray-light: #f1f5f9;
    --border: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8fafc;
    min-height: 100vh;
    color: #334155;
    font-size: 14px;
}

.wrapper {
    display: flex;
    min-height: 100vh;
}

#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    background: var(--dark);
    transition: margin-left 0.3s;
}

#sidebar.collapsed {
    margin-left: calc(var(--sidebar-width) * -1);
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h5 {
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h5 i {
    font-size: 1.5rem;
    color: var(--primary);
}

#sidebar .nav {
    padding: 0.75rem;
}

#sidebar .nav-item {
    margin-bottom: 2px;
}

#sidebar .nav-link {
    color: rgba(255, 255, 255, 0.6);
    padding: 10px 14px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

#sidebar .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

#sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

#sidebar .nav-link.active {
    color: #fff;
    background: var(--primary);
}

#content {
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
    transition: all 0.3s;
    min-height: 100vh;
}

#content.expanded {
    width: 100%;
    margin-left: 0;
}

#content > .navbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

#sidebarToggle {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--dark);
    border: none;
}

#sidebarToggle:hover {
    background: var(--dark-light);
}

main {
    padding: 1.5rem;
}

.card {
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: none;
    background: #fff;
}

.card:hover {
    box-shadow: none;
    transform: none;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: #fafbfc;
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
}

.stat-card {
    border-left: 3px solid var(--primary);
}

.stat-card.sent {
    border-left-color: #22c55e;
}

.stat-card.failed {
    border-left-color: #ef4444;
}

.stat-card.pending {
    border-left-color: #f59e0b;
}

.stat-card .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-card h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0;
}

.stat-card small {
    color: var(--gray);
    font-size: 0.8rem;
}

.btn {
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.btn-whatsapp {
    background: var(--primary);
    border: none;
    color: #fff;
}

.btn-whatsapp:hover {
    background: var(--primary-dark);
    color: #fff;
}

.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    color: var(--gray);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    background: #fafbfc;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    color: #475569;
}

.table-hover tbody tr:hover {
    background: #f8fafc;
}

.badge {
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-weight: 600;
    color: var(--dark);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h2 i {
    color: var(--primary);
}

.page-header p {
    color: var(--gray);
    font-size: 0.9rem;
}

.page-header a {
    color: var(--primary);
    text-decoration: none;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--dark);
}

.login-card {
    width: 100%;
    max-width: 380px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.login-card .card-header {
    background: var(--primary);
    color: #fff;
    text-align: center;
    padding: 2rem 1.5rem;
    border: none;
}

.login-card .card-header i {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    display: block;
}

.login-card .card-header h4 {
    font-weight: 600;
    font-size: 1.25rem;
    margin: 0;
}

.login-card .card-body {
    padding: 2rem 1.5rem;
    background: #fff;
}

.form-label {
    font-weight: 500;
    color: var(--dark);
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid var(--border);
    padding: 10px 12px;
    font-size: 0.9rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.input-group-text {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 6px 0 0 6px;
    color: var(--gray);
    padding: 10px 12px;
}

.input-group .form-control {
    border-left: none;
    border-radius: 0 6px 6px 0;
}

.input-group:focus-within .input-group-text {
    border-color: var(--primary);
    color: var(--primary);
}

.qr-container {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    border: 1px dashed var(--border);
}

.qr-container img {
    max-width: 200px;
    border-radius: 6px;
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--gray);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #cbd5e1;
}

.empty-state h5 {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.contact-avatar {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.loading-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal-content {
    border: none;
    border-radius: 8px;
}

.modal-header {
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
}

.modal-title {
    font-weight: 600;
    color: var(--dark);
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    background: #fafbfc;
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
}

.alert {
    border: none;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

.progress {
    height: 6px;
    border-radius: 3px;
    background: var(--border);
}

.progress-bar {
    border-radius: 3px;
    background: var(--primary);
}

.campaign-progress {
    height: 4px;
}

.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: #f1f5f9;
}

.nav-tabs {
    border-bottom: 1px solid var(--border);
}

.nav-tabs .nav-link {
    border: none;
    color: var(--gray);
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: 6px 6px 0 0;
}

.nav-tabs .nav-link:hover {
    color: var(--primary);
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    background: #fff;
    border-bottom: 2px solid var(--primary);
}

.form-check-input {
    width: 1em;
    height: 1em;
    border: 1px solid #cbd5e1;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.list-group-item {
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
}

.list-group-item:last-child {
    border-bottom: none;
}

.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.show {
    display: block;
}

@media (max-width: 768px) {
    #sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
    }

    #sidebar.show {
        margin-left: 0;
    }

    #content {
        width: 100%;
        margin-left: 0;
    }

    main {
        padding: 1rem;
        padding-bottom: 70px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .page-header h2 {
        font-size: 1.25rem;
    }

    .stat-card .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .stat-card h3 {
        font-size: 1.25rem;
    }

    .table-responsive {
        font-size: 0.8rem;
    }

    .table th, .table td {
        padding: 0.5rem;
    }

    .card-header, .card-body, .card-footer {
        padding: 0.75rem;
    }

    .btn {
        padding: 6px 12px;
    }

    .btn-sm {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .modal-dialog {
        margin: 0.5rem;
    }

    .alert {
        font-size: 0.85rem;
    }

    .d-flex.gap-1 {
        gap: 0.25rem !important;
    }

    .d-flex.gap-2 {
        gap: 0.5rem !important;
    }
}

@media (max-width: 576px) {
    .page-header h2 {
        font-size: 1.1rem;
    }

    .stat-card h3 {
        font-size: 1.1rem;
    }

    .stat-card small {
        font-size: 0.7rem;
    }

    .stat-card .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .card-footer .d-flex {
        flex-wrap: wrap;
    }

    .btn-group-mobile {
        width: 100%;
    }

    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-state i {
        font-size: 3rem;
    }
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    z-index: 1000;
    padding: 0.5rem;
}

.mobile-bottom-nav .nav {
    display: flex;
    justify-content: space-around;
}

.mobile-bottom-nav .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--gray);
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    text-decoration: none;
}

.mobile-bottom-nav .nav-link i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.mobile-bottom-nav .nav-link.active {
    color: var(--primary);
}

.mobile-bottom-nav .nav-link:hover {
    color: var(--primary);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: block;
    }
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.detail-table {
    width: 100%;
}

.detail-table th {
    width: 120px;
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.85rem;
    vertical-align: top;
    padding: 0.75rem;
    border: 1px solid var(--border);
}

.detail-table td {
    padding: 0.75rem;
    border: 1px solid var(--border);
    word-break: break-word;
}

.detail-table pre {
    margin: 0;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
    background: #f8fafc;
    padding: 0.5rem;
    border-radius: 4px;
}

@media (max-width: 576px) {
    .detail-table th,
    .detail-table td {
        display: block;
        width: 100%;
    }

    .detail-table th {
        border-bottom: none;
    }

    .detail-table td {
        border-top: none;
    }
}
