/* ========================================
   Sistema de Tickets P&D - GRUPO FAJ
   Estilos Globais
   ======================================== */

/* Variables */
:root {
    --color-primary: #1e40af;
    --color-primary-dark: #1e3a8a;
    --color-primary-light: #3b82f6;
    --color-secondary: #64748b;
    --color-success: #22c55e;
    --color-success-light: #dcfce7;
    --color-warning: #f59e0b;
    --color-warning-light: #fef3c7;
    --color-error: #ef4444;
    --color-error-light: #fee2e2;
    --color-background: #f4f6f9;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-border: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--color-background);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ========================================
   Header
   ======================================== */
.header {
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
}

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

.logo-highlight {
    color: var(--color-primary);
}

.nav {
    display: flex;
    gap: 1rem;
}

.nav-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-weight: 500;
}

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

.nav-link.active {
    background: var(--color-primary);
    color: white;
}

/* ========================================
   Main Content
   ======================================== */
.main {
    flex: 1;
    padding: 2rem 0;
}

/* ========================================
   Cards
   ======================================== */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--color-border);
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.card-subtitle {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

/* ========================================
   Form Elements
   ======================================== */
.form {
    padding: 2rem;
}

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

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

.required {
    color: var(--color-error);
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    transition: var(--transition);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

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

.form-input.error,
.form-select.error {
    border-color: var(--color-error);
}

.form-error {
    display: block;
    color: var(--color-error);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    min-height: 1.25rem;
}

/* Editor Container (Quill) */
#editor-container {
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

#editor {
    min-height: 200px;
    font-size: 1rem;
}

.ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-background);
}

.ql-container.ql-snow {
    border: none;
}

/* ========================================
   Upload Area
   ======================================== */
.upload-area {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--color-primary);
    background: rgba(30, 64, 175, 0.05);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.upload-text {
    color: var(--color-text);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.upload-hint {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.upload-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Preview Container */
.preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.preview-item {
    position: relative;
    width: 120px;
}

.preview-image {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.preview-video {
    width: 120px;
    height: 90px;
    background: var(--color-text);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
}

.preview-name {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--color-error);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-remove:hover {
    background: #dc2626;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

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

.btn-primary:disabled {
    background: var(--color-secondary);
    cursor: not-allowed;
}

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

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

.form-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.btn-text,
.btn-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ========================================
   Spinner
   ======================================== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner.large {
    width: 40px;
    height: 40px;
    border-width: 3px;
    border-color: rgba(30, 64, 175, 0.2);
    border-top-color: var(--color-primary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Modal
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: modalIn 0.3s ease;
}

.modal-large {
    max-width: 700px;
    text-align: left;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    cursor: pointer;
}

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

.modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.modal-icon.success {
    background: var(--color-success-light);
    color: var(--color-success);
}

.modal-icon.error {
    background: var(--color-error-light);
    color: var(--color-error);
}

.modal-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-text {
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.ticket-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    font-family: monospace;
    margin: 1rem 0;
}

/* ========================================
   Footer
   ======================================== */
.footer {
    background: var(--color-surface);
    padding: 1rem 0;
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    border-top: 1px solid var(--color-border);
}

/* ========================================
   Hidden Utility
   ======================================== */
.hidden {
    display: none !important;
}

/* ========================================
   Admin Panel Styles
   ======================================== */

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

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

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

.stat-icon.blue {
    background: rgba(30, 64, 175, 0.1);
}

.stat-icon.yellow {
    background: rgba(245, 158, 11, 0.1);
}

.stat-icon.green {
    background: rgba(34, 197, 94, 0.1);
}

.stat-icon.purple {
    background: rgba(139, 92, 246, 0.1);
}

.stat-icon.red {
    background: rgba(239, 68, 68, 0.1);
}

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

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

.stat-label {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

/* Filters Bar */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 1.5rem;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

.search-box .form-input {
    margin: 0;
}

.filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filters .form-select {
    width: auto;
    min-width: 150px;
}

/* Alert */
.alert-card {
    padding: 0;
}

.alert {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
}

.alert-warning {
    background: var(--color-warning-light);
}

.alert-icon {
    font-size: 1.5rem;
}

.alert-content h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.alert-content p {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.alert-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-family: monospace;
}

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

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

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table th {
    background: var(--color-background);
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr:hover {
    background: var(--color-background);
}

.table td {
    font-size: 0.9375rem;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-open,
.badge-aberto {
    background: var(--color-warning-light);
    color: #b45309;
}

.badge-progress,
.badge-em_andamento {
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-primary);
}

.badge-resolved,
.badge-resolvido {
    background: var(--color-success-light);
    color: #15803d;
}

.badge-closed,
.badge-fechado {
    background: var(--color-background);
    color: var(--color-text-secondary);
}

.badge-aguardando_info {
    background: rgba(139, 92, 246, 0.1);
    color: #7c3aed;
}

.badge-cancelado {
    background: var(--color-error-light);
    color: var(--color-error);
}

/* Badge de Atrasado */
.badge-atrasado {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: var(--color-error);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    margin-left: 0.5rem;
}

/* Linha de ticket atrasado */
.row-atrasado {
    background: rgba(239, 68, 68, 0.05);
}

.row-atrasado:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

/* Empty State */
.empty-state,
.loading-state {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-secondary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.loading-state p {
    margin-top: 1rem;
}

/* Ticket Detail Modal */
.ticket-detail {
    padding: 1rem;
}

.ticket-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ticket-id {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    background: var(--color-background);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.ticket-subject {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.ticket-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--color-background);
    border-radius: var(--radius-md);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-label {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-value {
    font-weight: 500;
}

.ticket-description h3,
.ticket-attachments h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--color-text);
}

.description-content {
    padding: 1rem;
    background: var(--color-background);
    border-radius: var(--radius-md);
    line-height: 1.7;
}

.ticket-attachments {
    margin-top: 1.5rem;
}

.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-background);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

/* Attachment Gallery */
.attachment-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.attachment-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 150px;
}

.attachment-thumb a {
    display: block;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--color-border);
    transition: var(--transition);
}

.attachment-thumb a:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.attachment-img {
    width: 150px;
    height: 110px;
    object-fit: cover;
    display: block;
}

.attachment-thumb-video {
    width: 250px;
}

.attachment-video {
    width: 250px;
    max-height: 180px;
    border-radius: var(--radius-md);
    border: 2px solid var(--color-border);
    background: #000;
}

.attachment-name {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Ticket Actions */
.ticket-actions {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.ticket-actions h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.action-group {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--color-background);
    border-radius: var(--radius-md);
}

.action-group .form-label {
    margin-bottom: 0.75rem;
}

.action-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.action-row .form-select {
    flex: 1;
    max-width: 250px;
}

/* Textarea */
.form-textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

/* Hint Text */
.hint-text {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-top: 0.75rem;
}

/* Resposta Existente */
.ticket-resposta {
    margin-top: 1.5rem;
}

.ticket-resposta h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--color-success);
}

.resposta-content {
    padding: 1rem;
    background: var(--color-success-light);
    border-left: 4px solid var(--color-success);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.resposta-texto {
    color: var(--color-text);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.resposta-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
}

/* Action Buttons in Table */
.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--color-background);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .nav {
        width: 100%;
        justify-content: center;
    }

    .form {
        padding: 1rem;
    }

    .modal-content {
        margin: 1rem;
        padding: 1.5rem;
    }

    .filters-bar {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    .filters {
        width: 100%;
        justify-content: stretch;
    }

    .filters .form-select {
        flex: 1;
    }

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

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

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

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

    .btn {
        width: 100%;
    }
}
