/**
 * CSS Customizado para o Sistema de Timer de Eventos
 * 
 * Design mobile-first com aparência de aplicativo
 * Foco em acessibilidade, contraste e usabilidade
 */

/* ========================================
   RESET E VARIÁVEIS CSS
   ======================================== */

:root {
    /* Cores Principais - Paleta Moderna */
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    --overtime-color: #64748b;
    --overtime-bg: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    
    /* Cores de Background - Gradiente Moderno */
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-dark: #0f172a;
    --bg-card: #ffffff;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Tipografia */
    --font-primary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
    
    /* Espaçamentos */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Sombras - Mais Suaves e Modernas */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Border Radius - Mais Arredondado */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Altura Máxima da App */
    --app-max-width: 480px;
    
    /* Transições */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   ESTILOS GLOBAIS
   ======================================== */

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

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--bg-dark);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========================================
   CONTAINER PRINCIPAL DA APLICAÇÃO
   ======================================== */

.app-container {
    max-width: var(--app-max-width);
    margin: 0 auto;
    min-height: 100vh;
    background-color: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

/* ========================================
   HEADER
   ======================================== */

.app-header {
    background: var(--bg-gradient);
    color: white;
    padding: 1.25rem var(--spacing-md);
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    text-align: center;
    justify-content: center;
    letter-spacing: -0.02em;
    font-family: var(--font-display);
}

/* ========================================
   CONTEÚDO PRINCIPAL
   ======================================== */

.app-content {
    flex: 1;
    padding: var(--spacing-sm);
    overflow-y: auto;
}

/* Espaçamento entre seções */
.app-content > section {
    margin-bottom: var(--spacing-md);
}

/* ========================================
   CARD PRINCIPAL DO TIMER
   ======================================== */

.timer-main-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-xl);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.timer-main-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 30px -5px rgba(0, 0, 0, 0.15), 0 15px 15px -5px rgba(0, 0, 0, 0.08);
}

/* Timer Principal do Evento */
.event-timer-section {
    text-align: center;
    padding: var(--spacing-md) 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(118, 75, 162, 0.05));
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
}

.event-timer-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-sm);
}

.event-timer-header i {
    font-size: 1.1rem;
    color: var(--primary-color);
}

.event-timer-display {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: var(--font-display);
    color: var(--primary-color);
    letter-spacing: 0.05em;
}

/* Controles do Timer do Evento */
.event-timer-controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: var(--spacing-sm);
}

.btn-event-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-event-control i {
    font-size: 1rem;
}

.btn-event-start {
    background: var(--success-color);
    color: white;
}

.btn-event-start:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-event-pause {
    background: var(--warning-color);
    color: white;
    padding: 0.5rem 0.75rem;
}

.btn-event-pause:hover {
    background: #d97706;
}

.btn-event-stop {
    background: var(--danger-color);
    color: white;
}

.btn-event-stop:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* Estado do timer do evento rodando */
.event-timer-section.running .event-timer-display {
    color: var(--success-color);
    animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.timer-divider {
    border: none;
    border-top: 2px solid var(--bg-primary);
    margin: var(--spacing-md) 0;
}

/* Cabeçalho do Segmento */
.segment-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--bg-primary);
}

.segment-badge {
    background: var(--bg-gradient);
    color: white;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast);
}

.segment-badge:hover {
    transform: scale(1.05);
}

.segment-info-header {
    flex: 1;
    min-width: 0;
}

.segment-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--bg-dark);
    margin: 0 0 0.25rem 0;
    line-height: 1.2;
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

.participant-name {
    font-size: 0.95rem;
    color: var(--secondary-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-weight: 500;
}

.participant-name i {
    font-size: 1.1rem;
}

/* Display do Tempo Principal */
.timer-main-display {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.timer-display {
    font-size: 5rem;
    font-weight: 800;
    color: var(--bg-dark);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
    font-family: var(--font-display);
    line-height: 1;
    transition: color var(--transition-base), transform var(--transition-fast);
}

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

/* Estado de alerta quando o tempo está acabando */
.timer-display.warning {
    color: var(--warning-color);
    animation: pulse-warning 1s infinite;
}

.timer-display.danger {
    color: var(--danger-color);
    animation: pulse-danger 0.5s infinite;
    transform: scale(1.05);
}

.timer-display.overtime {
    color: var(--overtime-color);
    animation: pulse-overtime 1.5s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.02);
    }
}

@keyframes pulse-danger {
    0%, 100% {
        opacity: 1;
        transform: scale(1.05);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.08);
    }
}

@keyframes pulse-overtime {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.85;
        transform: scale(1.02);
    }
}

/* Animação de pulso discreto ao entrar em overtime */
.overtime-pulse {
    animation: overtime-pulse-once 1s ease-out;
}

@keyframes overtime-pulse-once {
    0% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(100, 116, 139, 0.7);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(100, 116, 139, 0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(100, 116, 139, 0);
    }
}

/* ========================================
   BARRA DE PROGRESSO
   ======================================== */

.progress-wrapper {
    margin-bottom: var(--spacing-lg);
}

.progress {
    height: 12px;
    border-radius: var(--radius-full);
    background-color: var(--bg-primary);
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.progress-bar {
    background: var(--bg-gradient);
    transition: width var(--transition-base) ease-out, background var(--transition-base) ease-out;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.progress-bar.overtime {
    background: var(--overtime-bg);
    box-shadow: 0 0 10px rgba(100, 116, 139, 0.5);
    animation: none;
}

/* ========================================
   CONTROLES DO TIMER
   ======================================== */

/* Controles Principais */
.main-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.btn-main-control {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: none;
    font-weight: 700;
    font-size: 1.125rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 100px;
    transition: all var(--transition-fast);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    font-family: var(--font-display);
}

.btn-main-control i {
    font-size: 2rem;
}

.btn-main-control:hover:not(:disabled) {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.btn-main-control:active:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-main-control:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-play {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
}

.btn-play:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669, var(--success-color));
}

.btn-pause {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: white;
}

.btn-pause:hover:not(:disabled) {
    background: linear-gradient(135deg, #d97706, var(--warning-color));
}

/* Controles Secundários */
.secondary-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
}

.btn-secondary-control {
    padding: 0.875rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--bg-primary);
    background: var(--bg-card);
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.btn-secondary-control i {
    font-size: 1.25rem;
}

.btn-secondary-control:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
    transform: translateY(-2px);
}

.btn-secondary-control:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary-control:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Botão Encerrar com destaque especial */
.btn-secondary-control.btn-finish {
    background: var(--success-color);
    color: white;
    font-weight: 700;
}

.btn-secondary-control.btn-finish:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
}

.btn-secondary-control.btn-finish:disabled {
    background: var(--secondary-color);
    opacity: 0.3;
}

/* ========================================
   PRÓXIMOS SEGMENTOS E HISTÓRICO
   ======================================== */

.upcoming-section,
.history-section {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-md);
}

.history-section {
    border-left: 4px solid var(--success-color);
}

/* Tempo Total do Evento no Histórico */
.event-total-time {
    background: linear-gradient(135deg, var(--bg-gradient) 0%, var(--bg-secondary) 100%);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    text-align: center;
    color: white;
}

.event-total-label {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.event-total-display {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.section-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    color: var(--bg-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
}

.section-header .badge {
    background: var(--bg-gradient);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.875rem;
}

/* ========================================
   BOTÃO ADICIONAR SEGMENTO
   ======================================== */

.btn-add-segment {
    width: 100%;
    padding: 1rem;
    background: var(--bg-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-md);
}

.btn-add-segment:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-add-segment:active {
    transform: translateY(0);
}

.btn-add-segment i {
    font-size: 1.5rem;
}

/* ========================================
   FORMULÁRIO DE ADICIONAR SEGMENTO
   ======================================== */

.add-segment-form {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-md);
    animation: slideDown var(--transition-base);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--bg-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.form-control {
    border-radius: var(--radius-md);
    padding: 0.875rem;
    border: 2px solid var(--bg-primary);
    transition: all var(--transition-fast);
    font-size: 1rem;
    width: 100%;
    background: var(--bg-card);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

.form-control.is-invalid {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-control.is-invalid:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.duration-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

.duration-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.duration-field small {
    text-align: center;
    font-size: 0.75rem;
    color: var(--secondary-color);
}

.btn-submit {
    width: 100%;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: var(--spacing-sm);
}

.btn-submit:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-submit:active {
    transform: translateY(0);
}

.btn-submit i {
    font-size: 1.25rem;
}

/* ========================================
   LISTA DE SEGMENTOS
   ======================================== */

.segments-list {
    max-height: 350px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--secondary-color) transparent;
}

.segments-list::-webkit-scrollbar {
    width: 6px;
}

.segments-list::-webkit-scrollbar-track {
    background: transparent;
}

.segments-list::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: var(--radius-full);
}

.segment-item {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    transition: all var(--transition-fast);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-primary);
    border: 2px solid transparent;
}

.segment-item:hover {
    background: rgba(99, 102, 241, 0.05);
    border-color: rgba(99, 102, 241, 0.2);
    transform: translateX(4px);
}

.segment-item:last-child {
    margin-bottom: 0;
}

.segment-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(118, 75, 162, 0.1));
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.segment-item.active .segment-info h4 {
    color: var(--primary-color);
}

.segment-item.completed {
    opacity: 0.5;
    background: rgba(16, 185, 129, 0.05);
}

.segment-item.completed .segment-info h4 {
    text-decoration: line-through;
}

.segment-info {
    flex: 1;
    min-width: 0;
}

.segment-info h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--bg-dark);
    line-height: 1.3;
    font-family: var(--font-display);
}

.segment-info p {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Segmento completado */
.segment-item.completed {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-left: 4px solid var(--success-color);
    opacity: 0.95;
}

.segment-item.completed .segment-info h4 {
    color: #166534;
}

.segment-item.completed .segment-info p {
    color: #15803d;
}

.segment-item.completed .segment-duration {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
}

.segment-item.completed .segment-actual-time {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--success-color);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.segment-item.completed .segment-variance {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.segment-item.completed .segment-variance.positive {
    background: #fee2e2;
    color: #991b1b;
}

.segment-item.completed .segment-variance.negative {
    background: #dcfce7;
    color: #166534;
}

.segment-item.completed .segment-variance.exact {
    background: #e0e7ff;
    color: #3730a3;
}

.segment-duration {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1rem;
    margin-right: 0.75rem;
    padding: 0.375rem 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-md);
    white-space: nowrap;
}

.segment-actions {
    display: flex;
    gap: 0.375rem;
}

.btn-sm-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: white;
    color: var(--secondary-color);
}

.btn-sm-icon:hover:not(:disabled) {
    transform: scale(1.15);
    box-shadow: var(--shadow-sm);
}

.btn-sm-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Estado Vazio */
.empty-state {
    padding: 2.5rem var(--spacing-md);
    text-align: center;
    color: var(--secondary-color);
}

.empty-state i {
    font-size: 3.5rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.3;
    color: var(--primary-color);
}

.empty-state p {
    margin-bottom: 0.25rem;
    font-weight: 600;
    font-size: 1rem;
    color: var(--bg-dark);
}

.empty-state small {
    font-size: 0.875rem;
    color: var(--secondary-color);
}

/* ========================================
   FOOTER
   ======================================== */

.app-footer {
    background: var(--bg-card);
    padding: var(--spacing-md);
    text-align: center;
    border-top: 2px solid var(--bg-primary);
    margin-top: auto;
}

.app-footer p {
    color: var(--secondary-color);
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
}

/* ========================================
   MODAL CUSTOMIZADO
   ======================================== */

/* Garantir que o modal de templates funcione corretamente */
#templateModal.modal {
    z-index: 1060 !important;
}

#templateModal .modal-backdrop {
    z-index: 1050 !important;
}

/* Garantir que o modal de configuração de meio de semana funcione corretamente */
#midweekConfigModal.modal {
    z-index: 1060 !important;
}

#midweekConfigModal .modal-backdrop {
    z-index: 1050 !important;
}

.modal-content {
    border-radius: var(--radius-xl);
    border: none;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem;
}

.modal-header.bg-warning {
    background: linear-gradient(135deg, var(--warning-color), #d97706) !important;
    color: white;
}

.modal-body {
    padding: 2rem;
}

.modal-body h4 {
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-family: var(--font-display);
}

/* Duração do Evento no Modal */
.event-duration-summary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.event-duration-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.event-duration-value {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Badge de Duração do Evento no Histórico */
.event-duration-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
}

.event-duration-badge i {
    font-size: 0.875rem;
}

.event-duration-badge strong {
    font-family: var(--font-mono);
}

.modal-footer {
    padding: 1.5rem;
    border-top: 2px solid var(--bg-primary);
}

.modal-footer .btn {
    padding: 0.75rem 2rem;
    border-radius: var(--radius-md);
    font-weight: 700;
}

/* ========================================
   RESPONSIVIDADE
   ======================================== */

/* Tablets e Pequenos Desktops */
@media (min-width: 768px) {
    .app-content {
        padding: var(--spacing-lg);
    }
    
    .timer-display {
        font-size: 6rem;
    }
    
    .main-controls {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .secondary-controls {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Dispositivos Pequenos */
@media (max-width: 576px) {
    .timer-display {
        font-size: 4rem;
    }
    
    .app-title {
        font-size: 1.125rem;
    }
    
    .segment-name {
        font-size: 1.25rem;
    }
    
    .btn-main-control {
        font-size: 1rem;
        min-height: 80px;
        padding: 1rem;
    }
    
    .btn-main-control i {
        font-size: 1.75rem;
    }
    
    .btn-secondary-control {
        font-size: 0.875rem;
        padding: 0.75rem;
    }
    
    .segment-badge {
        width: 48px;
        height: 48px;
        font-size: 0.75rem;
    }
}

/* ========================================
   ACESSIBILIDADE
   ======================================== */

/* Melhoria de foco para navegação por teclado */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Modo de alto contraste */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0056b3;
        --success-color: #155724;
        --danger-color: #b21f2d;
    }
    
    .form-control {
        border-width: 3px;
    }
}

/* Reduzir animações para usuários com preferência */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Modo escuro (opcional, pode ser ativado no futuro) */
@media (prefers-color-scheme: dark) {
    /* Comentado por enquanto, mas pronto para implementação */
    /*
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --bg-dark: #f8f9fa;
    }
    
    body {
        color: #f8f9fa;
    }
    */
}

/* ========================================
   ANIMAÇÕES E TRANSIÇÕES
   ======================================== */

.fade-in {
    animation: fadeIn var(--transition-base) ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Shake para erros */
.shake {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-8px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(8px);
    }
}

/* Animação de entrada suave */
.slide-up {
    animation: slideUp var(--transition-base) ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pulse suave */
.pulse-soft {
    animation: pulseSoft 2s ease-in-out infinite;
}

@keyframes pulseSoft {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* ========================================
   SISTEMA DE ALERTAS
   ======================================== */

/* Estados visuais do timer */
.alert-normal {
    transition: all 0.3s ease;
}

.alert-warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%) !important;
    animation: pulse-warning-alert 1s ease-in-out infinite;
}

.alert-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%) !important;
    animation: pulse-danger-alert 0.5s ease-in-out infinite;
}

/* Animações de pulso para alertas */
@keyframes pulse-warning-alert {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 10px 40px rgba(243, 156, 18, 0.4);
    }
    50% {
        transform: scale(1.01);
        box-shadow: 0 15px 50px rgba(243, 156, 18, 0.6);
    }
}

@keyframes pulse-danger-alert {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 10px 40px rgba(231, 76, 60, 0.5);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 15px 60px rgba(231, 76, 60, 0.8);
    }
}

/* Animação de shake para alertas */
.alert-shake {
    animation: alert-shake-animation 0.5s ease-in-out;
}

@keyframes alert-shake-animation {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Flash na tela */
.alert-flash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 9999;
}

.alert-flash-default {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 70%);
}

.alert-flash-success {
    background: radial-gradient(circle, rgba(46, 213, 115, 0.6) 0%, rgba(46, 213, 115, 0) 70%);
}

/* Controles de som */
.sound-controls {
    display: flex;
    align-items: center;
    padding: 10px 0;
    opacity: 1;
    transition: opacity 0.3s ease;
    justify-content: center;
}

/* ========================================
   MODAL DE RESUMO DE SEGMENTO
   ======================================== */

.segment-summary {
    padding: var(--spacing-md);
}

.segment-summary h4 {
    color: var(--primary-color);
    font-weight: 700;
    text-align: center;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.summary-stat {
    background: var(--bg-primary);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    text-align: center;
}

.summary-stat .stat-label {
    font-size: 0.875rem;
    color: var(--secondary-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-xs);
}

.summary-stat .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-display);
    color: var(--bg-dark);
}

.summary-stat.variance-positive .stat-value {
    color: var(--overtime-color);
}

.summary-stat.variance-negative .stat-value {
    color: var(--success-color);
}

.summary-stat.variance-exact .stat-value {
    color: var(--primary-color);
}

/* ========================================
   LABEL DE OVERTIME
   ======================================== */

.overtime-label {
    color: var(--overtime-color);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    animation: fade-in 0.3s ease-in-out;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   BOT\u00c3O ENCERRAR EM DESTAQUE
   ======================================== */

.btn-secondary-control.btn-finish-highlight {
    background: var(--overtime-bg);
    color: white;
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
    animation: pulse-button 1.5s ease-in-out infinite;
}

@keyframes pulse-button {
    0%, 100% {
        box-shadow: var(--shadow-lg);
    }
    50% {
        box-shadow: var(--shadow-xl);
    }
}


.sound-controls:hover {
    opacity: 1;
}

.sound-controls .btn {
    min-width: 100px;
    flex-shrink: 0;
    height: 44px;
}

.sound-controls .btn-muted {
    opacity: 0.6;
}

/* Responsividade para telas menores */
@media (max-width: 576px) {
    .sound-controls {
        gap: 0.5rem;
    }
    
    .sound-controls .btn {
        min-width: 80px;
        font-size: 0.85rem;
        padding: 0.65rem;
    }
    
    .sound-controls .form-range {
        width: 100px;
        min-width: 60px;
    }
}
/* ========================================
   HISTÓRICO
   ======================================== */

#historyList .card {
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

#historyList .card:hover {
    border-left-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateX(2px);
}

#historyList .btn-group-vertical .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

#historyStats .card {
    border: none;
    background: var(--bg-primary);
}

#historyStats .card-body h6 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.alert-info {
    background-color: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

/* ========================================
   BOTÕES DE COMPARTILHAMENTO
   ======================================== */

/* WhatsApp */
#btnShareWhatsApp {
    background-color: #25D366;
    border-color: #25D366;
}

#btnShareWhatsApp:hover {
    background-color: #1ea952;
    border-color: #1ea952;
}

/* Telegram */
#btnShareTelegram {
    background-color: #0088cc;
    border-color: #0088cc;
}

#btnShareTelegram:hover {
    background-color: #006ba1;
    border-color: #006ba1;
}

/* Gmail */
#btnShareGmail {
    background-color: #EA4335;
    border-color: #EA4335;
}

#btnShareGmail:hover {
    background-color: #c5352a;
    border-color: #c5352a;
}

/* Outlook */
#btnShareOutlook {
    background-color: #0078D4;
    border-color: #0078D4;
}

#btnShareOutlook:hover {
    background-color: #005a9e;
    border-color: #005a9e;
}

/* Teams */
#btnShareTeams {
    background-color: #6264A7;
    border-color: #6264A7;
}

#btnShareTeams:hover {
    background-color: #464775;
    border-color: #464775;
}

/* Ícone Teams customizado (fallback caso bi-microsoft-teams não exista) */
.bi-microsoft-teams::before {
    content: "\f4a0"; /* Bootstrap Icon para Teams ou fallback */
}

/* Animação para todos os botões de compartilhamento */
#shareModal .btn {
    transition: all 0.2s ease;
}

#shareModal .btn:active {
    transform: scale(0.98);
}

/* Mobile responsiveness */
@media (max-width: 576px) {
    #shareModal .row.g-2 {
        gap: 0.5rem !important;
    }
    
    #shareModal .btn {
        font-size: 0.875rem;
        padding: 0.5rem;
    }
}

/* ========================================
   TOUR GUIADO (ONBOARDING)
   ======================================== */

/* Overlay escuro de fundo */
.tour-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.75);
    z-index: 9998;
    animation: tourFadeIn 0.3s ease;
}

/* Caixa de destaque do elemento */
.tour-highlight {
    position: absolute;
    border: 3px solid var(--primary-color);
    border-radius: var(--radius-md);
    background-color: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.75);
    z-index: 9999;
    pointer-events: none;
    transition: all 0.3s ease;
    animation: tourPulse 2s infinite;
}

@keyframes tourPulse {
    0%, 100% {
        box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.75), 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.75), 0 0 0 10px rgba(99, 102, 241, 0);
    }
}

/* Tooltip do tour */
.tour-tooltip {
    position: absolute;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 0;
    width: 320px;
    max-width: calc(100vw - 40px);
    z-index: 10000;
    animation: tourSlideIn 0.3s ease;
    overflow: hidden;
}

.tour-tooltip-center {
    transform: translate(-50%, -50%);
    position: fixed;
}

@keyframes tourFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes tourSlideIn {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.tour-tooltip-center.tour-tooltip {
    animation: tourSlideInCenter 0.3s ease;
}

@keyframes tourSlideInCenter {
    from { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Header do tooltip */
.tour-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-gradient);
    color: white;
}

.tour-step-counter {
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0.9;
}

.tour-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.tour-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Título e conteúdo */
.tour-tooltip-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--bg-dark);
    margin: 1rem 1rem 0.5rem;
    line-height: 1.3;
}

.tour-tooltip-content {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin: 0 1rem 1rem;
    line-height: 1.6;
    white-space: pre-line;
}

/* Footer com botões de navegação */
.tour-tooltip-footer {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
    background-color: #f8fafc;
}

/* Botões do tour */
.tour-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tour-btn-prev {
    background-color: transparent;
    color: var(--secondary-color);
}

.tour-btn-prev:hover {
    background-color: #e2e8f0;
    color: var(--bg-dark);
}

.tour-btn-next {
    background: var(--bg-gradient);
    color: white;
}

.tour-btn-next:hover {
    opacity: 0.9;
    transform: translateX(2px);
}

.tour-btn-finish {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
}

.tour-btn-finish:hover {
    transform: translateX(0) scale(1.02);
}

/* Botão de Ajuda (Help) - Flutuante */
.help-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: var(--radius-full);
    background: var(--bg-gradient);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: all 0.3s ease;
}

.help-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

.help-button:active {
    transform: scale(0.95);
}

/* Tooltip do botão de ajuda */
.help-button::before {
    content: 'Ajuda';
    position: absolute;
    right: 60px;
    background: var(--bg-dark);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.help-button:hover::before {
    opacity: 1;
}

/* Responsividade do tour */
@media (max-width: 400px) {
    .tour-tooltip {
        width: calc(100vw - 20px);
    }
    
    .help-button {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
        bottom: 15px;
        right: 15px;
    }
}

/* Para telas muito grandes, limitar a área do tour */
@media (min-width: 768px) {
    .tour-overlay,
    .tour-highlight {
        /* Ajustar para funcionar dentro do app container */
    }
}

/* ========================================
   TEMPLATES DE REUNIÃO
   ======================================== */

/* Barra de ações dos segmentos */
.segment-actions-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

/* Botão de templates */
.btn-template {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    color: white;
    border: none;
    padding: 15px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-template:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.btn-template i {
    font-size: 1.2rem;
}

/* Ajustar botão adicionar parte */
.btn-add-segment {
    flex: 1;
}

/* Opções de template no modal */
.template-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.template-option {
    display: flex;
    align-items: center;
    padding: 20px;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.template-option:hover {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-2px);
}

.template-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 20px;
    flex-shrink: 0;
}

.template-icon i {
    color: white;
    font-size: 1.5rem;
}

.template-info h6 {
    margin: 0 0 8px 0;
    font-weight: 600;
    color: var(--text-color);
    font-size: 1.1rem;
}

.template-info p {
    margin: 0;
    color: #6b7280;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Configuração de partes meio de semana */
.template-parts-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.template-parts-option {
    flex: 1;
    min-width: 120px;
    padding: 15px 20px;
    border: 2px solid #e5e5e5;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.template-parts-option:hover {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

.template-parts-option input[type="radio"] {
    display: none;
}

.template-parts-option input[type="radio"]:checked + span {
    color: white;
}

.template-parts-option:has(input:checked) {
    border-color: var(--primary-color);
    background: var(--primary-color);
}

.template-parts-option span {
    font-weight: 600;
    font-size: 0.95rem;
}

/* Container de configuração das partes */
.parts-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e5e5e5;
}

.current-part-indicator {
    background: var(--primary-color);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.part-config-form {
    background: #f8fafc;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.parts-config-progress {
    margin-bottom: 15px;
}

.parts-config-progress .progress {
    height: 8px;
    background-color: #e5e5e5;
    border-radius: 4px;
    overflow: hidden;
}

.parts-config-progress .progress-bar {
    background: linear-gradient(90deg, var(--primary-color), #6366f1);
    transition: width 0.3s ease;
}

/* Responsividade para templates */
@media (max-width: 768px) {
    .segment-actions-bar {
        flex-direction: column;
    }
    
    .template-option {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }
    
    .template-icon {
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .template-parts-options {
        flex-direction: column;
    }
    
    .template-parts-option {
        min-width: 100%;
    }
}