/* ============================================================
   Sistema de Tickets - CSS
   ============================================================ */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #6b7280;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
    --radius: 8px;
}

/* Unread badge */
.unread-badge {
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

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

/* ============================================================
   LAYOUT
   ============================================================ */
.app-header {
    background: #1e1b4b;
    color: white;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-header nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-header nav a {
    color: rgba(255,255,255,.8);
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: .2s;
}

.app-header nav a:hover,
.app-header nav a.active {
    background: rgba(255,255,255,.15);
    color: white;
    text-decoration: none;
}

.user-badge {
    background: rgba(255,255,255,.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: rgba(255,255,255,.8);
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 24px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================================
   CARDS & FORMS
   ============================================================ */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.form-group {
    margin-bottom: 16px;
}

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color .2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

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

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: .2s;
    font-family: inherit;
    text-decoration: none;
}

.btn:hover { text-decoration: none; opacity: .9; transform: translateY(-1px); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ============================================================
   KANBAN BOARD
   ============================================================ */
.kanban-board {
    display: flex;
    gap: 8px;
    padding-bottom: 16px;
    min-height: 500px;
    width: 100%;
}

.kanban-column {
    flex: 1 1 0;
    min-width: 160px;
    background: var(--bg);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 140px);
}

.kanban-column-header {
    padding: 12px 14px;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--radius) var(--radius) 0 0;
    position: sticky;
    top: 0;
}

.kanban-column-header .count {
    background: rgba(0,0,0,.15);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.kanban-cards {
    padding: 8px;
    flex: 1;
    overflow-y: auto;
    min-height: 60px;
}

.kanban-card {
    background: white;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
    cursor: pointer;
    transition: .2s;
    border-left: 3px solid transparent;
}

.kanban-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.kanban-card.dragging {
    opacity: .5;
    transform: rotate(2deg);
}

.kanban-card .ticket-id {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 600;
}

.kanban-card .ticket-title {
    font-size: 13px;
    font-weight: 500;
    margin: 4px 0;
    line-height: 1.3;
}

.kanban-card .ticket-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-light);
    margin-top: 8px;
}

.kanban-card .ticket-deadline {
    display: flex;
    align-items: center;
    gap: 3px;
}

.kanban-card .sla-bar {
    height: 3px;
    border-radius: 2px;
    background: #e5e7eb;
    margin-top: 8px;
    overflow: hidden;
}

.kanban-card .sla-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width .3s;
}

.kanban-card .client-tag {
    font-size: 10px;
    background: #ede9fe;
    color: #7c3aed;
    padding: 1px 6px;
    border-radius: 3px;
}

/* Sortable placeholder */
.kanban-cards .sortable-ghost {
    opacity: .3;
    background: #c7d2fe;
}

/* ============================================================
   TICKET DETAIL
   ============================================================ */
.ticket-detail {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
}

.ticket-stage-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.ticket-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ticket-info-item {
    padding: 12px;
    background: var(--bg);
    border-radius: 6px;
}

.ticket-info-item label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.ticket-info-item .value {
    font-size: 15px;
    font-weight: 500;
    margin-top: 2px;
}

/* SLA */
.sla-widget {
    padding: 16px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 16px;
}

.sla-progress {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    margin: 8px 0;
    overflow: hidden;
}

.sla-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .5s;
}

/* Comments */
.comment-list {
    max-height: 500px;
    overflow-y: auto;
}

.comment-item {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-item.system {
    background: #f0fdf4;
    border-radius: 6px;
    margin-bottom: 4px;
    border: none;
    font-size: 12px;
    color: var(--text-light);
}

.comment-item .comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.comment-item .comment-author {
    font-weight: 600;
    font-size: 13px;
}

.comment-item .comment-role {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 6px;
}

.comment-item .comment-role.admin {
    background: #fef3c7;
    color: #92400e;
}

.comment-item .comment-role.operator {
    background: #dbeafe;
    color: #1e40af;
}

.comment-item .comment-time {
    font-size: 11px;
    color: var(--text-light);
}

.comment-item .comment-body {
    font-size: 13px;
    white-space: pre-wrap;
}

.comment-form textarea {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 300px;
    transition: border-color .2s, box-shadow .2s;
}

.comment-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

/* Files */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 13px;
}

.file-item .file-name {
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-item .file-size {
    font-size: 11px;
    color: var(--text-light);
}

/* ============================================================
   TABLE
   ============================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-light);
    background: var(--bg);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.data-table tr:hover td {
    background: #f9fafb;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ============================================================
   STAGE FLOW BUTTONS
   ============================================================ */
.stage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.stage-actions .btn {
    font-size: 12px;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-card h1 {
    font-size: 22px;
    margin-bottom: 6px;
}

.login-card p {
    color: var(--text-light);
    margin-bottom: 24px;
    font-size: 14px;
}

/* ============================================================
   WIP INDICATOR
   ============================================================ */
.wip-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
}

.wip-indicator.at-limit {
    color: var(--danger);
}

.wip-indicator.ok {
    color: var(--success);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .ticket-detail {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .kanban-column {
        flex: 0 0 240px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .container {
        padding: 16px;
    }
}

/* ============================================================
   DRAG HANDLE
   ============================================================ */
.drag-handle {
    cursor: grab;
    color: var(--text-light);
    font-size: 14px;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    margin-bottom: 16px;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}

.tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: .2s;
}

.tab.active,
.tab:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Priority */
.priority-card {
    background: #fef2f2 !important;
    border-left-width: 4px !important;
}

.priority-badge {
    background: #fee2e2;
    color: #dc2626;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
}

.btn-priority {
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .2s;
}

.btn-priority:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.btn-priority.active {
    background: #fee2e2;
    border-color: #ef4444;
}

/* Quill editor overrides */
.ql-toolbar.ql-snow {
    border-radius: var(--radius) var(--radius) 0 0;
    border-color: var(--border);
}
.ql-container.ql-snow {
    border-radius: 0 0 var(--radius) var(--radius);
    border-color: var(--border);
    font-family: inherit;
    font-size: 14px;
}
.ql-editor {
    min-height: 120px;
}
.ql-editor-view {
    font-size: 13px;
}
.ql-editor-view p {
    margin-bottom: 8px;
}
.ql-editor-view ul, .ql-editor-view ol {
    padding-left: 20px;
    margin-bottom: 8px;
}
