/**
 * Style formularzy dla Scrum Poker Online
 * scrumonline.eu
 * 
 * Kompatybilny z PHP 8.4 i nowoczesnymi przeglądarkami
 */

/* ===== PODSTAWOWE STYLE FORMULARZY ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.label-text {
    display: inline-block;
}

.label-required {
    color: var(--error-color);
    margin-left: 0.25rem;
    font-weight: 700;
}

/* ===== POLA TEKSTOWE ===== */
.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: all 0.2s ease-in-out;
    font-family: inherit;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input:hover,
.form-textarea:hover,
.form-select:hover {
    border-color: var(--border-dark);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

/* Textarea specyficzne style */
.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ===== RADIO BUTTONS I CHECKBOXY ===== */
.form-radio,
.form-checkbox {
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.form-radio {
    border-radius: 50%;
}

.form-radio:checked,
.form-checkbox:checked {
    background-color: var(--primary-color);
}

.form-radio:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0.5rem;
    height: 0.5rem;
    background-color: white;
    border-radius: 50%;
}

.form-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1;
}

.form-radio:focus,
.form-checkbox:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== POMOC I KOMUNIKATY ===== */
.form-help {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.form-error {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--error-color);
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.form-error::before {
    content: '⚠️';
    font-size: 1rem;
}

.form-success {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--success-color);
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.form-success::before {
    content: '✅';
    font-size: 1rem;
}

/* ===== PRZYCISKI FORMULARZY ===== */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    overflow: hidden;
    min-height: 3rem;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Podstawowy przycisk */
.btn-primary {
    background-color: var(--primary-color);
    color: #1a1a1a;
    border-color: var(--primary-color);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #1a1a1a;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

/* Przycisk obramowany */
.btn-outline {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: #1a1a1a;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Rozmiary przycisków */
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 2.5rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    min-height: 3.5rem;
}

/* Ikony w przyciskach */
.btn-icon {
    font-size: 1.125em;
    line-height: 1;
    pointer-events: none; /* Przepuszcza kliknięcia do przycisku */
}

/* Loading state */
.btn-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: inherit;
    color: inherit;
}

.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== RESPONSYWNOŚĆ ===== */
@media (max-width: 768px) {
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .form-input,
    .form-textarea,
    .form-select {
        font-size: 16px; /* Zapobiega zoom na iOS */
    }
}

/* ===== DARK MODE ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1e293b;
        --bg-secondary: #334155;
        --bg-tertiary: #475569;
        --bg-card: #1e293b;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --border-color: #475569;
        --border-light: #334155;
        --border-dark: #64748b;
    }
    
    .form-input,
    .form-textarea,
    .form-select {
        background-color: var(--bg-secondary);
        color: var(--text-primary);
    }
    
    .form-radio,
    .form-checkbox {
        background-color: var(--bg-secondary);
    }
}

/* ===== WALIDACJA ===== */
.form-input:invalid,
.form-textarea:invalid,
.form-select:invalid {
    border-color: var(--error-color);
}



/* Ukryj domyślne komunikaty walidacji */
.form-input:invalid:not(:focus):not(:placeholder-shown),
.form-textarea:invalid:not(:focus):not(:placeholder-shown) {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* ===== ACCESSIBILITY ===== */
.form-input:focus-visible,
.form-textarea:focus-visible,
.form-select:focus-visible,
.form-radio:focus-visible,
.form-checkbox:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Wysokie kontrast */
@media (prefers-contrast: high) {
    .form-input,
    .form-textarea,
    .form-select {
        border-width: 3px;
    }
    
    .btn {
        border-width: 3px;
    }
}

/* Redukcja animacji */
@media (prefers-reduced-motion: reduce) {
    .form-input,
    .form-textarea,
    .form-select,
    .form-radio,
    .form-checkbox,
    .btn {
        transition: none;
    }
    
    .spinner {
        animation: none;
    }
}

/* ===== NOWE ELEMENTY FORMULARZA ===== */

/* Label optional i badge */
.label-optional {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.8125rem;
    margin-left: 0.25rem;
}

.label-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.125rem 0.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Select dropdown */
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
    padding-right: 3rem;
    cursor: pointer;
}

/* Opcje grid (dla disabled opcji) */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-item:hover:not(.option-item-disabled) {
    border-color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.05);
}

.option-item-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--bg-secondary);
}

.option-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
}

.option-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.option-text {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ===== MODALE ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

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

.modal-container {
    background-color: var(--bg-primary);
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

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

.modal-container-danger {
    border: 2px solid var(--error-color);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    border-radius: 0.375rem;
}

.modal-close:hover {
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    border-radius: 0 0 1rem 1rem;
}

/* Warning message w modalu */
.warning-message {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background-color: rgba(239, 68, 68, 0.1);
    border: 2px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.5rem;
}

.warning-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.warning-text {
    flex: 1;
}

.warning-text p {
    margin: 0 0 0.5rem 0;
}

.warning-text ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.warning-text li {
    margin: 0.25rem 0;
}

.room-name-display {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(239, 68, 68, 0.2);
}

/* Danger button */
.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.4);
}

/* ===== RESPONSYWNOŚĆ ===== */
@media (max-width: 640px) {
    .options-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-container {
        max-width: 100%;
        border-radius: 1rem 1rem 0 0;
        margin-top: auto;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}
