/* ==========================================================================
   NATAN PLAST ERP - UNIFIED FORMS & INTERACTIVE DESIGN SYSTEM
   Applies consistent high-end styling across Panel Kierownika, Planowanie Produkcji,
   Settings, and Modals.
   ========================================================================== */

/* 1. Global Reset & Font Settings for Form Elements */
input, select, textarea, button {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    box-sizing: border-box;
}

/* 2. Base Input Elements (Text, Number, Date, Select, Textarea, etc.) */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="tel"],
input[type="url"],
.form-control,
.form-input,
.search-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: #111827;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* Placeholder styling */
input::placeholder,
textarea::placeholder,
.form-control::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

/* 3. Focus & Hover States */
input[type="text"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
input[type="datetime-local"]:hover,
input[type="time"]:hover,
input[type="month"]:hover,
input[type="password"]:hover,
input[type="email"]:hover,
input[type="search"]:hover,
select:hover,
textarea:hover,
.form-control:hover,
.form-input:hover {
    border-color: #9ca3af;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
input[type="month"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-input:focus {
    border-color: #111827 !important;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.1), 0 1px 2px rgba(0, 0, 0, 0.05) !important;
    background-color: #ffffff !important;
}

/* Disabled & Readonly */
input:disabled,
select:disabled,
textarea:disabled,
input[readonly],
textarea[readonly],
.form-control:disabled,
.form-control[readonly] {
    background-color: #f9fafb !important;
    color: #6b7280 !important;
    border-color: #e5e7eb !important;
    cursor: not-allowed;
}

/* 4. Textarea Special Styling */
textarea,
.form-control-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
    padding: 12px 14px;
}

/* 5. Select Styling (Custom SVG Arrow Indicator) */
select,
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%234B5563'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px 16px;
    padding-right: 40px;
    cursor: pointer;
}

/* 6. Calendar & Date Pickers (`input[type="date"]`, `datetime-local`, `time`) */
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"] {
    position: relative;
    cursor: pointer;
}

/* Webkit calendar picker icon customization */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.75;
    padding: 4px;
    filter: invert(0.2);
    pointer-events: none !important;
}

/* 7. Checkbox & Radio Buttons */
.checkbox-container,
.form-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 8px;
    margin-bottom: 20px;
}

input[type="checkbox"],
input[type="radio"],
.form-check-input {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    accent-color: #111827;
    flex-shrink: 0;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

input[type="radio"] {
    border-radius: 50%;
}

.checkbox-text label,
.form-check-label {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    margin-bottom: 2px;
    cursor: pointer;
}

.helper-text {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

/* 8. Labels & Form Group Layouts */
label,
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.form-group-full {
    width: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

/* 9. Unified Master Button System */
.btn,
.btn-primary,
.btn-secondary,
.btn-office-primary,
.btn-office-secondary,
.btn-modal-primary,
.btn-modal-ghost,
.btn-modal,
.btn-action,
.btn-top,
.btn-add-order,
.btn-approve,
.btn-reject,
.btn-propose,
.action-btn,
button:not(.close-btn):not(.modal-close):not(.custom-select-trigger):not(.nav-item) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    transition: all 0.2s ease-in-out;
    text-decoration: none;
    border: 1px solid transparent;
    box-sizing: border-box;
    outline: none;
    white-space: nowrap;
}

.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-office-primary:active,
.btn-modal-primary:active,
.btn-action:active,
button:active {
    transform: translateY(1px);
}

/* Primary Variant */
.btn-primary,
.btn-office-primary,
.btn-modal-primary,
.btn-add-order {
    background-color: #1D4ED8 !important;
    border-color: #1D4ED8 !important;
    color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover,
.btn-office-primary:hover,
.btn-modal-primary:hover,
.btn-add-order:hover {
    background-color: #1e40af !important;
    border-color: #1e40af !important;
    color: #ffffff !important;
}

/* Secondary / Ghost Variant */
.btn-secondary,
.btn-office-secondary,
.btn-modal-ghost,
.btn-top,
.btn-propose {
    background-color: #ffffff !important;
    border: 1px solid #d1d5db !important;
    color: #374151 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-secondary:hover,
.btn-office-secondary:hover,
.btn-modal-ghost:hover,
.btn-top:hover,
.btn-propose:hover {
    background-color: #f9fafb !important;
    border-color: #9ca3af !important;
    color: #111827 !important;
}

/* Danger Variant */
.btn-danger,
.btn-office-danger,
.btn-reject {
    background-color: #fef2f2 !important;
    border: 1px solid #fecaca !important;
    color: #ef4444 !important;
}

.btn-danger:hover,
.btn-office-danger:hover,
.btn-reject:hover {
    background-color: #fee2e2 !important;
    border-color: #fca5a5 !important;
    color: #dc2626 !important;
}

/* Success Variant */
.btn-success,
.btn-approve {
    background-color: #f0fdf4 !important;
    border: 1px solid #bbf7d0 !important;
    color: #16a34a !important;
}

.btn-success:hover,
.btn-approve:hover {
    background-color: #dcfce7 !important;
    border-color: #86efac !important;
    color: #15803d !important;
}

/* 10. Modals & Cards */
.modal-card,
.modal-box {
    background-color: #ffffff;
    width: 100%;
    max-width: 560px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 32px;
    position: relative;
    border: 1px solid #e5e7eb;
}

.modal-header,
.header {
    margin-bottom: 24px;
}

.modal-title,
.title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 14px;
    color: #6b7280;
}

.close-btn,
.modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: none;
    border: none;
    font-size: 22px;
    color: #6b7280;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.close-btn:hover,
.modal-close:hover {
    color: #111827;
}

.footer-buttons,
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid #e5e7eb;
    padding-top: 24px;
    margin-top: 28px;
}

/* 11. Badges & Status Pills */
.badge,
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-amber,
.s-oczekujace {
    background: #fff7ed;
    color: #b45309;
    border: 1px solid #fde68a;
}

.badge-blue {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.badge-green,
.s-zatwierdzone {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.badge-red,
.s-odrzucone {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.badge-slate {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

/* 12. Media Query Responsiveness */
@media (max-width: 640px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .footer-buttons,
    .modal-footer {
        flex-direction: column;
        gap: 12px;
    }
    .btn {
        width: 100%;
    }
}

/* 13. Interactive ATP Delivery Calendar Popover */
.atp-calendar-popover {
    position: absolute;
    z-index: 10050;
    width: 350px;
    max-width: 95vw;
    box-sizing: border-box !important;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 20px 30px -10px rgba(15, 23, 42, 0.15), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
    padding: 16px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    animation: atpPopoverIn 0.15s ease-out;
}

.atp-calendar-popover * {
    box-sizing: border-box !important;
}

@keyframes atpPopoverIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.atp-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.atp-cal-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.atp-cal-nav {
    display: flex;
    gap: 4px;
}

.atp-cal-nav-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
    font-size: 11px;
    transition: all 0.15s ease;
}

.atp-cal-nav-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.atp-cal-legend {
    display: flex;
    gap: 6px;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 6px 10px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.atp-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.atp-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.atp-legend-dot.green { background: #10b981; }
.atp-legend-dot.orange { background: #f59e0b; }
.atp-legend-dot.red { background: #ef4444; }
.atp-legend-dot.white { background: #ffffff; border: 1px solid #cbd5e1; }

.atp-cal-days-header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    text-align: center;
    font-size: 10px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 8px;
    width: 100%;
}

.atp-cal-days-header span {
    padding: 4px 0;
    background: #f1f5f9;
    border-radius: 4px;
    display: block;
}

.atp-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
}

.atp-day {
    width: 100%;
    height: 38px;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    border: 1px solid #e2e8f0;
    margin: 0;
    padding: 0;
}

.atp-day.empty {
    border: none;
    background: transparent;
    cursor: default;
}

/* Green = Delivery possible */
.atp-day-green {
    background-color: #dcfce7 !important;
    color: #15803d !important;
    border-color: #86efac !important;
}
.atp-day-green:hover {
    background-color: #bbf7d0 !important;
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

/* Orange = Delivery impossible / deficit */
.atp-day-orange {
    background-color: #fff7ed !important;
    color: #c2410c !important;
    border-color: #fde68a !important;
}
.atp-day-orange:hover {
    background-color: #ffedd5 !important;
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

/* Red = Production impossible / Brak możliwości produkcji */
.atp-day-red {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
    border-color: #fca5a5 !important;
}
.atp-day-red:hover {
    background-color: #fee2e2 !important;
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.25);
}

/* White = No data / neutral */
.atp-day-white {
    background-color: #ffffff !important;
    color: #374151 !important;
    border-color: #e5e7eb !important;
}
.atp-day-white:hover {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
}

/* Selected active day */
.atp-day.is-selected {
    outline: 2px solid #111827;
    outline-offset: 1px;
}

/* 14. Custom Dropdown System */
.custom-select-container {
    position: relative;
    width: 100%;
    user-select: none;
    box-sizing: border-box;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    height: auto !important;
    box-shadow: none !important;
}

.custom-select-trigger {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: #111827;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.custom-select-trigger:hover {
    border-color: #9ca3af;
}

.custom-select-container.is-open .custom-select-trigger {
    border-color: #111827 !important;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.1) !important;
}

.custom-select-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: left;
}

.custom-select-arrow {
    color: #4b5563;
    font-size: 12px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.custom-select-container.is-open .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    box-shadow: 0 12px 28px -6px rgba(15, 23, 42, 0.15), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
    z-index: 10040;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: atpPopoverIn 0.15s ease-out;
}

.custom-select-container.is-open .custom-select-dropdown,
.custom-select-dropdown.is-fixed {
    display: flex;
}

.custom-select-dropdown.is-fixed {
    position: fixed;
    right: auto;
    z-index: 10050;
}

.custom-select-search-box {
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-select-search-box i {
    color: #94a3b8;
    font-size: 13px;
}

.custom-select-search-input {
    width: 100%;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 13px !important;
    padding: 0 !important;
    color: #0f172a;
}

.custom-select-options-list {
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.custom-select-option {
    padding: 10px 14px;
    font-size: 13.5px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    border-bottom: 1px solid #f8fafc;
    text-align: left;
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
}

.custom-select-option:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.custom-select-option.is-selected {
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
}

/* 15. Mobile Toggle Visibility (Strictly Hidden on Desktop) */
.mobile-toggle {
    display: none !important;
}

@media (max-width: 1024px) {
    .mobile-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* 16. ATP Calendar Right-Click Context Menu */
.atp-context-menu {
    position: absolute;
    z-index: 10060;
    width: 290px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 25px 40px -12px rgba(15, 23, 42, 0.3), 0 10px 15px -5px rgba(15, 23, 42, 0.1);
    padding: 14px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    animation: atpPopoverIn 0.15s ease-out;
}

.atp-context-header {
    display: flex;

/* 17. Pallet Auto-Rounding Badges */
.pallet-rounding-badges {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.badge-pallet-round {
    display: inline-flex;
    align-items: center;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.badge-pallet-round:hover {
    background: #1d4ed8;
    color: #ffffff;
    border-color: #1d4ed8;
}
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.atp-context-title {
    font-size: 13px;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 6px;
}

.atp-context-capacity-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 11.5px;
    color: #475569;
}

.atp-context-capacity-val {
    font-size: 16px;
    font-weight: 800;
    color: #1D4ED8;
    margin-top: 3px;
    letter-spacing: -0.01em;
}

.atp-context-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.atp-context-btn {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.atp-context-btn-primary {
    background: #1D4ED8;
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(29, 78, 216, 0.2);
}

.atp-context-btn-primary:hover {
    background: #1e40af;
}

.atp-context-btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

.atp-context-input-row {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.atp-context-input {
    flex: 1;
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    outline: none;
    font-weight: 700;
    color: #0f172a;
}

.atp-context-input:focus {
    border-color: #1D4ED8;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}
