/* Sistema SUA - Estilos Personalizados */

:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-bg: #0f172a;
    --dark-secondary: #1e293b;
    --dark-tertiary: #334155;
    --light-text: #f1f5f9;
    --gray-text: #94a3b8;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--dark-bg);
    color: var(--light-text);
    min-height: 100vh;
}

/* Topbar */
.topbar {
    background: var(--dark-secondary);
    border-bottom: 1px solid var(--dark-tertiary);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-text);
    font-size: 0.875rem;
}

.btn-logout {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: #dc2626;
}

/* Layout */
.app-container {
    display: flex;
    min-height: calc(100vh - 65px);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark-secondary);
    border-right: 1px solid var(--dark-tertiary);
    padding: 1.5rem 0;
    transition: all 0.3s ease;
    position: relative;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    padding: 0;
    overflow: hidden;
}

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

.sidebar-nav li {
    margin-bottom: 0.25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: var(--gray-text);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9375rem;
    white-space: nowrap;
}

.sidebar-nav a:hover {
    background: var(--dark-tertiary);
    color: var(--light-text);
}

.sidebar-nav a.active {
    background: var(--primary-color);
    color: white;
    border-right: 3px solid var(--primary-dark);
}

.sidebar-nav i {
    width: 1.25rem;
    text-align: center;
    font-size: 1.125rem;
}

/* Toggle Button */
.sidebar-toggle {
    position: fixed;
    bottom: 2rem;
    left: 1rem;
    width: 3rem;
    height: 3rem;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    transition: all 0.2s;
    z-index: 101;
}

.sidebar-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-x: hidden;
}

/* Cards */
.card {
    background: var(--dark-secondary);
    border: 1px solid var(--dark-tertiary);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--dark-tertiary);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--light-text);
}

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

.stat-card {
    background: linear-gradient(135deg, var(--dark-secondary) 0%, var(--dark-tertiary) 100%);
    border: 1px solid var(--dark-tertiary);
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-label {
    color: var(--gray-text);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.stat-value.primary { color: var(--primary-color); }
.stat-value.success { color: var(--success-color); }
.stat-value.warning { color: var(--warning-color); }

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--gray-text);
    font-size: 0.875rem;
    font-weight: 500;
}

.form-control, .form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--dark-bg);
    border: 1px solid var(--dark-tertiary);
    border-radius: 0.375rem;
    color: var(--light-text);
    font-size: 0.9375rem;
    transition: border-color 0.2s;
}

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

.form-control::placeholder {
    color: var(--secondary-color);
}

.form-inline {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: end;
}

.form-inline .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 200px;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
}

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

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

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

.btn-success:hover {
    background: #059669;
}

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

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

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

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

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

.btn-warning:hover {
    background: #d97706;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 0.5rem;
    background: var(--dark-bg);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

table.data-table thead {
    background: var(--dark-tertiary);
}

table.data-table th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--light-text);
    border-bottom: 2px solid var(--dark-tertiary);
    white-space: nowrap;
}

table.data-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--dark-tertiary);
    color: var(--gray-text);
}

table.data-table tbody tr {
    transition: background 0.2s;
}

table.data-table tbody tr:hover {
    background: var(--dark-tertiary);
}

table.data-table tfoot {
    background: var(--dark-tertiary);
    font-weight: 600;
}

table.data-table tfoot td {
    color: var(--light-text);
}

/* Tags */
.tag {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tag-primary { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.tag-success { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.tag-warning { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.tag-danger { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* Notifications */
.notification {
    position: fixed;
    top: 5rem;
    right: 1.5rem;
    max-width: 400px;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

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

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

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

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

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--dark-secondary);
    border: 1px solid var(--dark-tertiary);
    border-radius: 0.75rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--light-text);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--gray-text);
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--dark-tertiary);
    color: var(--light-text);
}

.modal-body {
    padding: 1.5rem;
}

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

/* TomSelect Override */
.ts-wrapper {
    min-width: 200px;
}

.ts-control {
    background: var(--dark-bg) !important;
    border: 1px solid var(--dark-tertiary) !important;
    color: var(--light-text) !important;
    padding: 0.375rem 0.875rem !important;
}

.ts-dropdown {
    background: var(--dark-secondary) !important;
    border: 1px solid var(--dark-tertiary) !important;
}

.ts-dropdown-content .option {
    color: var(--light-text) !important;
    padding: 0.5rem 0.875rem !important;
}

.ts-dropdown-content .option:hover,
.ts-dropdown-content .option.active {
    background: var(--dark-tertiary) !important;
}

/* Flatpickr Override */
.flatpickr-calendar {
    background: var(--dark-secondary) !important;
    border: 1px solid var(--dark-tertiary) !important;
}

.flatpickr-months {
    background: var(--dark-tertiary) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: var(--dark-bg) !important;
    color: var(--light-text) !important;
}

.flatpickr-day {
    color: var(--light-text) !important;
}

.flatpickr-day:hover {
    background: var(--dark-tertiary) !important;
}

.flatpickr-day.selected {
    background: var(--primary-color) !important;
}

/* DataTables Override */
.dataTables_wrapper {
    color: var(--light-text);
    font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_filter input {
    background: var(--dark-bg) !important;
    border: 1px solid var(--dark-tertiary) !important;
    color: var(--light-text) !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 0.375rem !important;
    margin-left: 0.5rem !important;
}

.dataTables_filter input:focus {
    outline: none !important;
    border-color: var(--primary-color) !important;
}

.dataTables_length select {
    background: var(--dark-bg) !important;
    border: 1px solid var(--dark-tertiary) !important;
    color: var(--light-text) !important;
    padding: 0.375rem 0.5rem !important;
    border-radius: 0.375rem !important;
    margin: 0 0.5rem !important;
}

.dataTables_info {
    color: var(--gray-text) !important;
    margin-top: 1rem;
    padding-top: 1rem !important;
}

.dataTables_paginate {
    margin-top: 1rem;
    padding-top: 1rem !important;
}

.paginate_button {
    padding: 0.5rem 0.875rem !important;
    margin: 0 0.125rem !important;
    border-radius: 0.375rem !important;
    border: 1px solid var(--dark-tertiary) !important;
    background: var(--dark-bg) !important;
    color: var(--light-text) !important;
    cursor: pointer !important;
}

.paginate_button:hover {
    background: var(--dark-tertiary) !important;
    border-color: var(--dark-tertiary) !important;
    color: var(--light-text) !important;
}

.paginate_button.current {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

.paginate_button.disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

/* DataTables Buttons */
.dt-buttons {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dt-button {
    background: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    padding: 0.5rem 1rem !important;
    border-radius: 0.375rem !important;
    font-size: 0.875rem !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
}

.dt-button:hover {
    background: var(--primary-dark) !important;
}

/* DataTables Processing */
.dataTables_processing {
    background: var(--dark-secondary) !important;
    color: var(--light-text) !important;
    border: 1px solid var(--dark-tertiary) !important;
    border-radius: 0.5rem !important;
    padding: 1rem !important;
}

/* DataTables Responsive */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
    background-color: var(--primary-color) !important;
    border: none !important;
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.5) !important;
}

table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control:before {
    background-color: var(--danger-color) !important;
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.5) !important;
}

table.dataTable > tbody > tr.child ul.dtr-details {
    width: 100%;
}

table.dataTable > tbody > tr.child ul.dtr-details > li {
    border-bottom: 1px solid var(--dark-tertiary) !important;
    padding: 0.75rem 0 !important;
}

table.dataTable > tbody > tr.child span.dtr-title {
    color: var(--gray-text) !important;
    font-weight: 600 !important;
    min-width: 120px !important;
}

table.dataTable > tbody > tr.child span.dtr-data {
    color: var(--light-text) !important;
}

/* Sidebar Backdrop for Mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 98;
    top: 65px;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 65px;
        height: calc(100vh - 65px);
        z-index: 99;
        transform: translateX(-100%);
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.4);
    }

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

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .main-content {
        padding: 1rem;
    }

    /* Forms */
    .form-inline {
        flex-direction: column;
    }

    .form-inline .form-group {
        width: 100%;
        min-width: auto;
    }

    .form-control,
    .form-select {
        min-height: 48px;
        font-size: 1rem;
        padding: 0.75rem;
    }

    /* Buttons - Touch Friendly */
    .btn {
        min-height: 48px;
        padding: 0.75rem 1rem;
        width: 100%;
        justify-content: center;
    }

    .btn-sm {
        min-height: 40px;
        padding: 0.5rem 0.875rem;
        width: auto;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

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

    /* Topbar */
    .topbar {
        padding: 0.75rem 1rem;
    }

    .topbar-title {
        font-size: 1.25rem;
    }

    .user-info span {
        display: none;
    }

    .user-info i {
        display: inline-block;
    }

    .btn-logout {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    /* Cards */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 0.5rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }

    .card-title {
        font-size: 1.125rem;
    }

    /* Modals */
    .modal {
        max-width: calc(100vw - 2rem);
        max-height: calc(100vh - 2rem);
        margin: 1rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }

    /* Tables */
    .table-container {
        margin: -1rem;
        width: calc(100% + 2rem);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table.data-table {
        min-width: 600px;
    }

    table.data-table th,
    table.data-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8125rem;
    }

    /* DataTables Controls */
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        margin-bottom: 0.75rem;
    }

    .dataTables_filter input {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0.5rem 0 0 0 !important;
    }

    .dataTables_wrapper .dataTables_filter label {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .dt-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }

    .dt-button {
        width: 100% !important;
        justify-content: center;
        text-align: center;
    }

    /* Notifications */
    .notification {
        left: 1rem;
        right: 1rem;
        max-width: calc(100vw - 2rem);
        font-size: 0.875rem;
        padding: 0.875rem 1rem;
    }

    /* Sidebar Toggle Button */
    .sidebar-toggle {
        bottom: 1.5rem;
        left: 1rem;
        width: 3.5rem;
        height: 3.5rem;
        font-size: 1.25rem;
    }

    /* TomSelect */
    .ts-wrapper {
        min-width: 100%;
    }

    .ts-control {
        min-height: 48px !important;
        padding: 0.75rem !important;
    }

    .ts-dropdown {
        max-height: 60vh !important;
        overflow-y: auto !important;
    }
}

/* Extra Small Devices */
@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem;
    }

    .card {
        padding: 0.875rem;
        border-radius: 0.375rem;
    }

    .topbar-title {
        font-size: 1.125rem;
    }

    .topbar-title i {
        font-size: 1rem;
    }

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

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

    .card-header {
        gap: 0.75rem;
    }

    .modal {
        max-width: 100vw;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }

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

    .sidebar-toggle {
        bottom: 1rem;
        width: 3rem;
        height: 3rem;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.ml-auto { margin-left: auto; }
.d-flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
