/**
 * New Ticket Page Styles
 *
 * Style dla strony tworzenia nowego ticketu
 * Używa globalnego systemu theme (dark/light) z theme.css
 *
 * @package ATFPRO
 * @since 1.0.0
 */

/* ==========================================================================
   Page Container
   ========================================================================== */

.atfpro-new-ticket-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.atfpro-new-ticket-page h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--theme-heading);
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.atfpro-new-ticket-page .page-description {
    color: var(--theme-text-muted);
    font-size: 1rem;
    margin-bottom: 2rem;
    transition: color 0.3s ease;
}

/* ==========================================================================
   Form Container
   ========================================================================== */

.atfpro-new-ticket-form .ticket-form {
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--theme-shadow-sm);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* ==========================================================================
   Form Sections
   ========================================================================== */

.form-section {
    margin-bottom: 2.5rem;
}

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

.form-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--theme-heading);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--theme-border);
    transition: color 0.3s ease, border-color 0.3s ease;
}

.form-section .section-description {
    color: var(--theme-text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    transition: color 0.3s ease;
}

/* ==========================================================================
   Form Rows & Groups
   ========================================================================== */

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-row.two-columns {
    grid-template-columns: 1fr 1fr;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--theme-text);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.3s ease;
}

.form-group label .required {
    color: var(--theme-error);
}

.form-group .field-hint {
    font-size: 0.75rem;
    color: var(--theme-text-muted);
    margin-top: 0.25rem;
    transition: color 0.3s ease;
}

/* ==========================================================================
   Form Inputs
   ========================================================================== */

.form-group input[type="text"],
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid var(--theme-input-border);
    border-radius: var(--radius-base);
    font-size: 1rem;
    font-family: var(--font-base);
    color: var(--theme-input-text);
    background: var(--theme-input-bg);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--theme-link);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group select {
    cursor: pointer;
    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='%236c757d' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
    appearance: none;
}

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

/* ==========================================================================
   WordPress Editor
   ========================================================================== */

.wp-editor-container {
    border: 1px solid var(--theme-border);
    border-radius: var(--radius-base);
    overflow: hidden;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    background: var(--theme-input-bg);
}

.wp-editor-container .mce-tinymce,
.wp-editor-container .mce-stack-layout,
.wp-editor-container .mce-edit-area {
    border: none;
    background: var(--theme-input-bg) !important;
}

.wp-editor-container textarea {
    border: none;
    border-radius: 0;
    background: var(--theme-input-bg);
    color: var(--theme-input-text);
}

/* Toolbar TinyMCE w dark mode — przyciski + tło */
body[data-theme="dark"] .wp-editor-container .mce-toolbar-grp,
body[data-theme="dark"] .wp-editor-container .mce-menubar,
body[data-theme="dark"] .wp-editor-container .mce-statusbar {
    background: #0d0d0d !important;
    border-color: #222 !important;
}

body[data-theme="dark"] .wp-editor-container .mce-btn {
    background: transparent;
    border-color: transparent;
}

body[data-theme="dark"] .wp-editor-container .mce-btn:hover,
body[data-theme="dark"] .wp-editor-container .mce-btn.mce-active {
    background: #1a1a1a !important;
    border-color: #333 !important;
}

body[data-theme="dark"] .wp-editor-container .mce-ico,
body[data-theme="dark"] .wp-editor-container .mce-btn button,
body[data-theme="dark"] .wp-editor-container .mce-path-item {
    color: #e9ecef !important;
}

body[data-theme="dark"] .wp-editor-container .mce-toolbar .mce-btn-group .mce-btn.mce-disabled .mce-ico {
    color: #555 !important;
}

/* Quicktags (text mode) — przyciski HTML */
body[data-theme="dark"] .wp-editor-container .quicktags-toolbar {
    background: #0d0d0d !important;
    border-color: #222 !important;
}

body[data-theme="dark"] .wp-editor-container .quicktags-toolbar input.button {
    background: #1a1a1a !important;
    border-color: #333 !important;
    color: #e9ecef !important;
}

body[data-theme="dark"] .wp-editor-container .quicktags-toolbar input.button:hover {
    background: #222 !important;
    border-color: #555 !important;
}

/* Switch HTML/Visual tabs */
body[data-theme="dark"] .wp-editor-tabs .wp-switch-editor {
    background: #1a1a1a !important;
    border-color: #333 !important;
    color: #e9ecef !important;
}

body[data-theme="dark"] .wp-editor-tabs .wp-switch-editor:hover,
body[data-theme="dark"] .wp-editor-tabs .wp-switch-editor:focus {
    background: #222 !important;
    color: #fff !important;
}

/* Tekstarea fallback (gdy TinyMCE jeszcze ładuje lub HTML tab) */
body[data-theme="dark"] .wp-editor-container textarea.wp-editor-area {
    background: #1a1a1a !important;
    color: #e9ecef !important;
}

/* ==========================================================================
   File Upload Section
   ========================================================================== */

.file-upload-section {
    margin-top: 1.5rem;
}

.file-upload-dropzone {
    border: 2px dashed var(--theme-border);
    border-radius: var(--radius-base);
    padding: 3rem 2rem;
    text-align: center;
    background: var(--theme-bg-alt);
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-upload-dropzone:hover {
    border-color: var(--theme-link);
    background: rgba(59, 130, 246, 0.05);
}

.file-upload-dropzone.dragover {
    border-color: var(--theme-link);
    background: rgba(59, 130, 246, 0.1);
    border-style: solid;
}

.dropzone-icon {
    margin-bottom: 1rem;
}

.dropzone-icon .dashicons {
    font-size: 3rem;
    width: 3rem;
    height: 3rem;
    color: var(--theme-text-muted);
    transition: color 0.3s ease;
}

.dropzone-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--theme-text);
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.dropzone-hint {
    font-size: 0.875rem;
    color: var(--theme-text-muted);
    margin-bottom: 1rem;
    transition: color 0.3s ease;
}

.dropzone-button {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: var(--color-button);
    color: var(--color-white);
    border-radius: var(--radius-base);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropzone-button:hover {
    background: var(--color-button-hover);
}

.file-input {
    display: none;
}

/* ==========================================================================
   Selected Files List
   ========================================================================== */

.selected-files-list {
    margin-top: 1.5rem;
}

.selected-files-list h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--theme-text);
    margin-bottom: 0.75rem;
    transition: color 0.3s ease;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--theme-bg-alt);
    border: 1px solid var(--theme-border);
    border-radius: var(--radius-base);
    margin-bottom: 0.5rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

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

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.file-icon .dashicons {
    font-size: 1.5rem;
    width: 1.5rem;
    height: 1.5rem;
    color: var(--theme-text-muted);
    transition: color 0.3s ease;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--theme-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s ease;
}

.file-size {
    font-size: 0.75rem;
    color: var(--theme-text-muted);
    margin-top: 0.125rem;
    transition: color 0.3s ease;
}

.file-remove {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid var(--theme-error);
    border-radius: var(--radius-base);
    color: var(--theme-error);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.file-remove:hover {
    background: var(--theme-error);
    color: var(--color-white);
}

/* ==========================================================================
   Form Actions
   ========================================================================== */

.form-actions {
    display: flex;
    gap: 1rem;
    padding-top: 2rem;
    border-top: 1px solid var(--theme-border);
    transition: border-color 0.3s ease;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-base);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn .dashicons {
    font-size: 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
}

.btn-primary {
    background: var(--color-button);
    color: var(--color-white);
}

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

.btn-primary:disabled {
    background: var(--theme-text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background: transparent;
    color: var(--theme-text);
    border: 1px solid var(--theme-border);
}

.btn-secondary:hover {
    background: var(--theme-card-bg-hover);
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.new-ticket-form.is-submitting {
    position: relative;
    pointer-events: none;
}

.new-ticket-form.is-submitting::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--theme-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-base);
    transition: background-color 0.3s ease;
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--color-white);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ==========================================================================
   Alert Messages
   ========================================================================== */

.ticket-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-base);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    position: relative;
}

.ticket-alert .dashicons {
    font-size: 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.ticket-alert-success {
    background: rgba(40, 167, 69, 0.1);
    border: 1px solid var(--theme-success);
    color: var(--theme-success);
}

.ticket-alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--theme-error);
    color: var(--theme-error);
}

.alert-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    padding: 0.25rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.alert-close:hover {
    opacity: 1;
}

/* ==========================================================================
   Brakujące klasy pomocnicze
   ========================================================================== */

/* Container — max-width i wyśrodkowanie */
.atfpro-new-ticket-page .container,
.atfpro-tickets-list .container,
.atfpro-ticket-history-page .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Tekst pomocy pod polami formularza */
.form-help {
    font-size: 0.8125rem;
    color: var(--theme-text-muted);
    margin-top: 0.375rem;
    line-height: 1.4;
    transition: color 0.3s ease;
}

/* Komunikaty formularza (sukces/błąd) */
.form-messages {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.form-messages.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--theme-error);
    color: var(--theme-error);
}

.form-messages.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--theme-success);
    color: var(--theme-success);
}

/* Alert ogólny (ostrzeżenie o braku maszyny) */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--theme-warning);
    color: var(--theme-warning);
}

/* Tekst "lub" w strefie uploadu — alias dla dropzone-hint */
.dropzone-subtitle {
    color: var(--theme-text-muted);
    font-size: 0.8125rem;
    margin: 0.5rem 0;
    transition: color 0.3s ease;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .atfpro-new-ticket-page {
        padding: 1rem 0.5rem;
    }

    .atfpro-new-ticket-page h1 {
        font-size: 1.5rem;
    }

    .atfpro-new-ticket-form .ticket-form {
        padding: 1.5rem 1rem;
    }

    .form-row.two-columns {
        grid-template-columns: 1fr;
    }

    .file-upload-dropzone {
        padding: 2rem 1rem;
    }

    .dropzone-icon .dashicons {
        font-size: 2rem;
        width: 2rem;
        height: 2rem;
    }

    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .file-info {
        width: 100%;
    }

    .file-remove {
        align-self: flex-end;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .atfpro-new-ticket-page h1 {
        font-size: 1.25rem;
    }

    .form-section h3 {
        font-size: 1.125rem;
    }

    .atfpro-new-ticket-form .ticket-form {
        padding: 1rem;
    }

    .file-upload-dropzone {
        padding: 1.5rem 0.75rem;
    }

    .dropzone-title {
        font-size: 0.875rem;
    }

    .dropzone-hint {
        font-size: 0.75rem;
    }
}
