/**
 * nova-faktura.css
 * Styling pre natívny SPA komponent novej faktúry
 */

/* ========================================
   FORM LAYOUT
   ======================================== */

.faktura-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.form-skupina {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-skupina h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

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

.form-field label {
    font-size: 14px;
    font-weight: 500;
    color: #555;
    margin-bottom: 5px;
}

.form-field label.required::after {
    content: ' *';
    color: #f44336;
}

.form-field input,
.form-field select,
.form-field textarea {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.form-field textarea {
    resize: vertical;
    min-height: 80px;
}

.form-field-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-field-inline label {
    margin-bottom: 0;
}

/* Error states */
.form-field.error input,
.form-field.error select,
.form-field.error textarea {
    border-color: #f44336;
}

.form-field.error .error-message {
    color: #f44336;
    font-size: 12px;
    margin-top: 5px;
}

.form-field.invalid input,
.form-field.invalid select,
.form-field.invalid textarea {
    border-color: #f44336;
    background-color: #fff5f5;
}

/* ========================================
   POLOŽKY TABLE
   ======================================== */

.polozky-section {
    margin: 30px 0;
}

.polozky-table-wrapper {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.polozky-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.polozky-table thead {
    background: #f5f5f5;
}

.polozky-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    font-size: 14px;
}

.polozky-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.polozky-table tbody tr:hover {
    background-color: #fafafa;
}

.polozky-table input,
.polozky-table select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.polozky-table input:focus,
.polozky-table select:focus {
    outline: none;
    border-color: #4CAF50;
}

.polozky-table .btn-remove {
    background: #f44336;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.polozky-table .btn-remove:hover {
    background: #d32f2f;
}

.btn-add-polozka {
    margin-top: 10px;
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-add-polozka:hover {
    background: #45a049;
}

/* ========================================
   SUMY SECTION
   ======================================== */

.sumy-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sumy-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.sumy-dph {
    border-right: 1px solid #e0e0e0;
    padding-right: 20px;
}

.sumy-celkom {
    padding-left: 20px;
}

.suma-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.suma-row:last-child {
    border-bottom: none;
}

.suma-row.total {
    font-weight: 600;
    font-size: 18px;
    color: #4CAF50;
    border-top: 2px solid #4CAF50;
    padding-top: 12px;
    margin-top: 8px;
}

.suma-label {
    color: #666;
}

.suma-value {
    font-weight: 500;
    color: #333;
}

/* ========================================
   BUTTONS
   ======================================== */

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.btn-secondary {
    background: #2196F3;
    color: white;
}

.btn-secondary:hover {
    background: #1976D2;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-outline {
    background: transparent;
    border: 2px solid #4CAF50;
    color: #4CAF50;
}

.btn-outline:hover {
    background: #4CAF50;
    color: white;
}

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

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 500px;
    padding: 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease-out;
}

.toast.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    font-size: 24px;
    font-weight: bold;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.toast-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #333;
}

/* Toast types */
.toast-success {
    border-left: 4px solid #4CAF50;
}

.toast-success .toast-icon {
    background: #4CAF50;
    color: white;
}

.toast-error {
    border-left: 4px solid #f44336;
}

.toast-error .toast-icon {
    background: #f44336;
    color: white;
}

.toast-warning {
    border-left: 4px solid #ff9800;
}

.toast-warning .toast-icon {
    background: #ff9800;
    color: white;
}

.toast-info {
    border-left: 4px solid #2196F3;
}

.toast-info .toast-icon {
    background: #2196F3;
    color: white;
}

/* ========================================
   LOADING SPINNER
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.loading-show {
    display: flex;
}

.loading-spinner {
    background: white;
    padding: 40px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-message {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* ========================================
   MODALS
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1200px) {
    .form-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .sumy-grid {
        grid-template-columns: 1fr;
    }
    
    .sumy-dph {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding-right: 0;
        padding-bottom: 20px;
    }
    
    .sumy-celkom {
        padding-left: 0;
        padding-top: 20px;
    }
}

@media (max-width: 768px) {
    .faktura-container {
        padding: 10px;
    }
    
    .form-grid,
    .form-grid-2,
    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: 1fr;
    }
    
    .form-skupina {
        padding: 15px;
    }
    
    .polozky-table-wrapper {
        overflow-x: scroll;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .toast-container {
        left: 10px;
        right: 10px;
    }
    
    .toast {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .form-skupina h3 {
        font-size: 16px;
    }
    
    .suma-row.total {
        font-size: 16px;
    }
    
    .modal {
        max-width: 95%;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.hidden {
    display: none !important;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.p-10 {
    padding: 10px;
}

.p-20 {
    padding: 20px;
}

/* ========================================
   FÁZA 3B - ROZŠÍRENIA
   ======================================== */

/* Modal Tabs */
.modal-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 20px;
}

.modal-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.modal-tab.active {
    color: #1a73e8;
    border-bottom-color: #1a73e8;
}

.modal-tab:hover {
    color: #1a73e8;
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.autocomplete-item:hover {
    background: #f0f0f0;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

/* Button Sizes */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* Table Wrapper */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

/* Loading States */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Form Field States */
.form-field.invalid input,
.form-field.invalid select,
.form-field.invalid textarea {
    border-color: #f44336;
    background-color: #fff5f5;
}

.form-field .error-message {
    color: #f44336;
    font-size: 12px;
    margin-top: 5px;
}

/* Modal Enhancements */
.modal {
    animation: modalSlideIn 0.3s ease-out;
}

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

/* Highlight Match */
.highlight-match {
    background: #ffeb3b;
    font-weight: 600;
}
