/* ============================================
   VARIÁVEIS E RESET
   ============================================ */

:root {
    --primary: #FFD700;
    --primary-dark: #FFC107;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --error: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;

    --bg-dark: #1a1a1a;
    --bg-darker: #0f0f0f;
    --bg-card: #252525;
    --bg-hover: #2d2d2d;

    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --text-success: #22c55e;
    --text-warning: #eab308;

    --border-color: #333333;
    --border-radius: 12px;
    --border-radius-sm: 8px;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.2);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-darker);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============================================
   UTILITÁRIOS
   ============================================ */

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ============================================
   BOTÕES
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: var(--bg-dark);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-outline-danger {
    background: transparent;
    color: #e74c3c;
    border: 1px solid #e74c3c;
}
.btn-outline-danger:hover {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}
.ml-1 { margin-left: 0.5rem; }

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    border: none;
}

.btn-icon:hover {
    color: var(--primary);
    background: rgba(255, 215, 0, 0.1);
}

.btn-block {
    width: 100%;
}

/* ============================================
   FORMULÁRIOS
   ============================================ */

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

.permissoes-grid {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.permissoes-grid .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.permissoes-grid .checkbox-label input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary);
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.password-toggle:hover {
    color: var(--primary);
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}


.modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@media (max-width: 600px) {
    .modal-content {
        width: 95%;
        margin: 10px;
        max-height: 85vh;
    }

    .modal-body {
        padding: 1rem;
    }
}


@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.modal-actions .btn-cancel-sm,
.btn-cancel-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-width: auto;
}

.modal-actions .btn-secondary:first-child {
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
}

.export-group {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.export-group .export-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.export-group .export-categoria-select {
    min-width: 160px;
    max-width: 200px;
}

/* ============================================
   TOAST
   ============================================ */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: toastSlideIn 0.3s ease;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.info {
    border-left: 4px solid var(--info);
}

/* ============================================
   GRID E LISTAS
   ============================================ */

.grid-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    transition: var(--transition);
    cursor: pointer;
}

.card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.card-body {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.text-success {
    color: var(--text-success) !important;
}

.text-warning {
    color: var(--text-warning) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.d-block {
    display: block;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: 0.5rem;
}

/* ============================================
   FILTROS
   ============================================ */

.filters {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.filter-input,
.filter-select {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================
   SCROLLBAR E CALENDÁRIOS (visual)
   ============================================ */

/* Scrollbar global - tema escuro */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--border-color);
}
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
*::-webkit-scrollbar-track {
    background: var(--bg-darker);
    border-radius: 5px;
}
*::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 5px;
}
*::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}
*::-webkit-scrollbar-corner {
    background: var(--bg-darker);
}

/* Inputs de data e hora - tema escuro, destaque em amarelo/dourado */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
    min-height: 42px;
    padding: 0.6rem 0.9rem;
    padding-right: 2.5rem;
    cursor: pointer;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
/* Reforço: classe explícita para garantir que o tema escuro aplique (evita cache/override) */
input.date-input-theme,
input.filter-input.date-input-theme {
    min-height: 44px !important;
    padding: 0.65rem 1rem !important;
    padding-right: 2.5rem !important;
    background: var(--bg-card) !important;
    border: 2px solid var(--border-color) !important;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary) !important;
    font-size: 0.95rem;
}
input.date-input-theme:hover,
input.filter-input.date-input-theme:hover {
    border-color: var(--primary) !important;
}
input.date-input-theme:focus,
input.filter-input.date-input-theme:focus {
    outline: none !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.25) !important;
}
input[type="date"]:hover,
input[type="datetime-local"]:hover,
input[type="time"]:hover {
    border-color: var(--primary);
}
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.2);
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0.9) sepia(0.3) saturate(5) hue-rotate(5deg);
    cursor: pointer;
    opacity: 0.9;
    margin-left: 0.25rem;
}
input.date-input-theme::-webkit-calendar-picker-indicator,
input.filter-input.date-input-theme::-webkit-calendar-picker-indicator {
    filter: invert(0.9) sepia(0.3) saturate(5) hue-rotate(5deg) !important;
    opacity: 1 !important;
}
input[type="date"]:focus::-webkit-calendar-picker-indicator,
input[type="datetime-local"]:focus::-webkit-calendar-picker-indicator {
    opacity: 1;
}
/* Placeholder e texto em inputs de data */
input[type="date"]::placeholder,
input[type="datetime-local"]::placeholder {
    color: var(--text-muted);
}

/* ============================================
   RESPONSIVIDADE
   ============================================ */

@media (max-width: 768px) {
    .grid-list {
        grid-template-columns: 1fr;
    }

    .filters {
        flex-direction: column;
    }

    .filter-input,
    .filter-select {
        width: 100%;
    }
}