/* Custom Support Tickets - Frontend Styles */

.cst-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Formulario de nuevo ticket */
.cst-new-ticket-form {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    /* display: none se controla via inline style en HTML */
}

.cst-new-ticket-form h3 {
    margin-top: 0;
    margin-bottom: 25px;
    color: #333;
    border-bottom: 2px solid #007cba;
    padding-bottom: 10px;
}

.cst-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 0;
}

.cst-form-group {
    margin-bottom: 20px;
}

.cst-form-group.cst-half {
    flex: 1;
}

.cst-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.cst-form-group input[type="text"],
.cst-form-group input[type="email"],
.cst-form-group select,
.cst-form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.cst-form-group input[type="text"]:focus,
.cst-form-group input[type="email"]:focus,
.cst-form-group select:focus,
.cst-form-group textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.cst-form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.cst-form-group input[type="file"] {
    padding: 8px;
    border: 2px dashed #ddd;
    border-radius: 4px;
    background: #fafafa;
    transition: border-color 0.3s ease;
}

.cst-form-group input[type="file"]:hover {
    border-color: #007cba;
}

.cst-form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

.cst-char-counter {
    text-align: right;
    color: #888;
}

.cst-char-counter.cst-warning {
    color: #ff6600;
}

.cst-char-counter.cst-danger {
    color: #dc3232;
}

/* Botones */
.cst-btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.cst-btn-primary {
    background: #007cba;
    color: white;
}

.cst-btn-primary:hover {
    background: #005a87;
    color: white;
}

.cst-btn-secondary {
    background: #f1f1f1;
    color: #333;
}

.cst-btn-secondary:hover {
    background: #e0e0e0;
    color: #333;
}

.cst-btn-small {
    padding: 8px 16px;
    font-size: 12px;
}

.cst-form-actions {
    margin-top: 25px;
    display: flex;
    gap: 15px;
}

/* Botón para nuevo ticket */
.cst-new-ticket-button-container {
    margin-bottom: 20px;
    text-align: left;
}

#cst-toggle-new-ticket-form {
    font-size: 15px;
    padding: 12px 24px;
}

#cst-toggle-new-ticket-form .cst-btn-icon {
    font-size: 20px;
    font-weight: bold;
    margin-right: 5px;
    vertical-align: middle;
    line-height: 1;
}

/* Contenedor horizontal para formulario y lista */
.cst-horizontal-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* Cuando el formulario está visible, ambos ocupan espacio */
.cst-horizontal-container .cst-new-ticket-form {
    flex: 0 0 48%;
    min-width: 0;
    max-width: 48%;
}

.cst-horizontal-container .cst-tickets-list {
    flex: 1 1 auto;
    min-width: 0;
    transition: all 0.3s ease;
}

/* Lista de tickets */
.cst-tickets-list {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 0; /* Sin margen inferior cuando está en horizontal */
}

.cst-tickets-list h3 {
    margin-top: 0;
    margin-bottom: 25px;
    color: #333;
    border-bottom: 2px solid #007cba;
    padding-bottom: 10px;
}

.cst-tickets-table {
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.cst-table-header,
.cst-table-row {
    display: grid;
    grid-template-columns: 80px 1fr 120px 120px 100px;
    gap: 0;
}

.cst-table-header {
    background: #f5f5f5;
    font-weight: 600;
    color: #333;
}

.cst-table-header > div,
.cst-table-row > div {
    padding: 15px 12px;
    border-right: 1px solid #ddd;
}

.cst-table-header > div:last-child,
.cst-table-row > div:last-child {
    border-right: none;
}

.cst-table-row {
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.cst-table-row:last-child {
    border-bottom: none;
}

.cst-table-row:hover {
    background: #f9f9f9;
}

.cst-col-subject a {
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
}

.cst-col-subject a:hover {
    text-decoration: underline;
}

/* Estados de tickets */
.cst-status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cst-status-open {
    background: #e3f2fd;
    color: #1976d2;
}

.cst-status-in-progress {
    background: #fff3e0;
    color: #f57c00;
}

.cst-status-waiting {
    background: #fce4ec;
    color: #c2185b;
}

.cst-status-resolved {
    background: #e8f5e8;
    color: #388e3c;
}

.cst-status-closed {
    background: #f5f5f5;
    color: #757575;
}

/* Vista individual del ticket */
.cst-ticket-view {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.cst-ticket-header {
    border-bottom: 1px solid #eee;
    margin-bottom: 25px;
    padding-bottom: 20px;
}

.cst-ticket-header h2 {
    margin: 0 0 15px 0;
    color: #333;
}

.cst-ticket-meta {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.cst-ticket-id {
    font-weight: 600;
    color: #666;
}

.cst-ticket-date {
    color: #888;
    font-size: 14px;
}

.cst-original-message {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-left: 4px solid #007cba;
    border-radius: 0 4px 4px 0;
}

.cst-original-message h4 {
    margin: 0 0 15px 0;
    color: #333;
}

.cst-message-content {
    line-height: 1.6;
}

/* Respuestas */
.cst-replies {
    margin-bottom: 30px;
}

.cst-reply {
    margin-bottom: 20px;
    padding: 20px;
    border-radius: 8px;
    position: relative;
}

.cst-reply-customer {
    background: #f0f8ff;
    border-left: 4px solid #007cba;
    margin-left: 0;
    margin-right: 40px;
}

.cst-reply-admin {
    background: #f0fff0;
    border-left: 4px solid #46b450;
    margin-left: 40px;
    margin-right: 0;
}

.cst-reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 14px;
}

.cst-reply-author {
    font-weight: 600;
    color: #333;
}

.cst-reply-date {
    color: #888;
}

.cst-reply-content {
    line-height: 1.6;
}

/* Formulario de respuesta */
.cst-reply-form {
    border-top: 1px solid #eee;
    padding-top: 25px;
}

.cst-reply-form h4 {
    margin: 0 0 20px 0;
    color: #333;
}

/* Mensajes */
.cst-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
}

.cst-message {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    animation: cst-slide-in 0.3s ease;
}

.cst-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.cst-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.cst-message-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

@keyframes cst-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading */
.cst-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.cst-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: cst-spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes cst-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cst-no-tickets {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

/* Archivos adjuntos */
.cst-attachments {
    margin-top: 15px;
}

.cst-attachment {
    display: inline-block;
    margin-right: 10px;
    margin-bottom: 5px;
    padding: 5px 10px;
    background: #f5f5f5;
    border-radius: 4px;
    text-decoration: none;
    color: #007cba;
    font-size: 12px;
}

.cst-attachment:hover {
    background: #e0e0e0;
}

/* Responsive */
@media (max-width: 1200px) {
    /* En pantallas medianas, cambiar a layout vertical */
    .cst-horizontal-container {
        flex-direction: column;
    }

    .cst-horizontal-container .cst-new-ticket-form,
    .cst-horizontal-container .cst-tickets-list {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .cst-container {
        padding: 15px;
    }

    .cst-form-row {
        flex-direction: column;
        gap: 0;
    }

    .cst-tickets-table {
        overflow-x: auto;
    }

    .cst-table-header,
    .cst-table-row {
        grid-template-columns: 60px 1fr 100px 100px 80px;
        min-width: 600px;
    }

    .cst-table-header > div,
    .cst-table-row > div {
        padding: 12px 8px;
    }

    .cst-ticket-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .cst-reply-customer {
        margin-right: 20px;
    }

    .cst-reply-admin {
        margin-left: 20px;
    }

    .cst-messages {
        left: 10px;
        right: 10px;
        max-width: none;
    }
}