/* ============================================
   Cedros Training Manager — Frontend Styles
   ============================================ */

:root {
    --ctm-primary: #1a5276;
    --ctm-primary-hover: #154360;
    --ctm-text: #2c3e50;
    --ctm-text-light: #5d6d7e;
    --ctm-border: #d5dbdb;
    --ctm-bg: #ffffff;
    --ctm-bg-light: #f8f9fa;
    --ctm-radius: 8px;
    --ctm-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --ctm-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --ctm-transition: 0.2s ease;
}

/* Grid */
.ctm-formacoes-grid {
    display: grid;
    grid-template-columns: repeat(var(--ctm-cols, 3), 1fr);
    gap: 24px;
    margin: 32px 0;
}

@media (max-width: 768px) {
    .ctm-formacoes-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .ctm-formacoes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Card */
.ctm-formacao-card {
    background: var(--ctm-bg);
    border: 1px solid var(--ctm-border);
    border-radius: var(--ctm-radius);
    overflow: hidden;
    box-shadow: var(--ctm-shadow);
    transition: box-shadow var(--ctm-transition), transform var(--ctm-transition);
    display: flex;
    flex-direction: column;
}

.ctm-formacao-card:hover {
    box-shadow: var(--ctm-shadow-hover);
    transform: translateY(-2px);
}

.ctm-card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.ctm-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ctm-card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.ctm-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--ctm-text);
    margin: 0 0 8px 0;
}

.ctm-card-description {
    font-size: 0.9rem;
    color: var(--ctm-text-light);
    margin: 0 0 16px 0;
    flex: 1;
    line-height: 1.5;
}

/* Table */
.ctm-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 32px 0;
}

.ctm-formacoes-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 0.95rem;
}

.ctm-formacoes-table thead th {
    background: #ef7203;
    color: #ffffff;
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    white-space: nowrap;
}

.ctm-formacoes-table thead th:last-child {
    text-align: center;
}

.ctm-formacoes-table tbody tr {
    border-bottom: 1px solid var(--ctm-border);
    transition: background var(--ctm-transition);
}

.ctm-formacoes-table tbody tr:nth-child(even) {
    background: var(--ctm-bg-light);
}

.ctm-formacoes-table tbody tr:hover {
    background: #eaf2f8;
}

.ctm-formacoes-table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    color: #111111;
}

.ctm-formacoes-table tbody td:first-child {
    color: #999999;
}

.ctm-formacoes-table tbody td:last-child {
    text-align: center;
}

.ctm-formacoes-table tbody td a {
    color: #999999;
    text-decoration: none;
    font-weight: 500;
}

.ctm-formacoes-table tbody td a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .ctm-formacoes-table {
        font-size: 0.85rem;
    }

    .ctm-formacoes-table thead th,
    .ctm-formacoes-table tbody td {
        padding: 10px 12px;
    }
}

/* Buttons */
.ctm-btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--ctm-radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background var(--ctm-transition), opacity var(--ctm-transition);
}

.ctm-btn-primary {
    background: var(--ctm-primary);
    color: #ffffff;
}

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

.ctm-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ctm-btn-inscrever {
    align-self: flex-start;
    margin-top: auto;
}

/* Modal */
.ctm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ctm-modal {
    background: var(--ctm-bg);
    border-radius: var(--ctm-radius);
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    position: relative;
}

.ctm-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--ctm-text-light);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

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

.ctm-modal-header {
    padding: 24px 24px 0;
}

.ctm-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--ctm-text);
}

.ctm-modal-body {
    padding: 16px 24px;
    overflow-y: auto;
    flex: 1;
}

.ctm-modal-loading {
    color: var(--ctm-text-light);
    font-style: italic;
}

.ctm-modal-footer {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--ctm-border);
    display: flex;
    justify-content: flex-end;
}

/* Slots list */
.ctm-slots-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ctm-slot-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border: 2px solid var(--ctm-border);
    border-radius: var(--ctm-radius);
    cursor: pointer;
    transition: border-color var(--ctm-transition), background var(--ctm-transition);
}

.ctm-slot-item:hover {
    border-color: var(--ctm-primary);
    background: var(--ctm-bg-light);
}

.ctm-slot-item.selected {
    border-color: var(--ctm-primary);
    background: var(--ctm-bg-light);
}

/* Full/sold-out slot */
.ctm-slot-item.ctm-slot-full {
    opacity: 0.55;
    cursor: not-allowed;
    background: var(--ctm-bg-light);
}

.ctm-slot-item.ctm-slot-full:hover {
    border-color: var(--ctm-border);
    background: var(--ctm-bg-light);
}

.ctm-slot-esgotado {
    font-weight: 600;
    color: #991b1b;
    background: #fef2f2;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.ctm-slot-item input[type="radio"] {
    margin-right: 12px;
    accent-color: var(--ctm-primary);
}

.ctm-slot-date {
    font-weight: 500;
    color: var(--ctm-text);
}

.ctm-slot-info {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--ctm-text-light);
}

/* Inscricao page */
.ctm-inscricao-wrapper {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 0;
}

.ctm-inscricao-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ctm-border);
}

.ctm-inscricao-header h2 {
    margin: 0 0 8px 0;
    color: var(--ctm-text);
}

.ctm-inscricao-date {
    color: var(--ctm-text-light);
    margin: 0;
}

/* Error messages */
.ctm-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: var(--ctm-radius);
}

/* No slots message */
.ctm-no-slots {
    color: var(--ctm-text-light);
    text-align: center;
    padding: 16px 0;
}

/* Success message */
.ctm-success-message {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
    padding: 24px;
    border-radius: var(--ctm-radius);
    text-align: center;
}

.ctm-success-icon {
    display: block;
    font-size: 2.5rem;
    margin-bottom: 12px;
    color: #16a34a;
}

.ctm-success-message p {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.6;
}

/* Hide the theme banner on the inscription page */
.ctm-inscricao-page .main-banner.type2 {
    display: none;
}
