/* Reset i podstawowe style */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #2196F3;
    color: white;
}

.btn-secondary:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

.btn-small {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 4px;
    background: #f0f0f0;
    border: 1px solid #ddd;
}

.btn-small:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

/* Flash messages */
.flash-message {
    padding: 1rem 2rem;
    margin: 0;
    font-weight: 500;
}

.flash-success {
    background: #d4edda;
    color: #155724;
    border-bottom: 3px solid #4CAF50;
}

.flash-error {
    background: #f8d7da;
    color: #721c24;
    border-bottom: 3px solid #f44336;
}

.flash-info {
    background: #d1ecf1;
    color: #0c5460;
    border-bottom: 3px solid #2196F3;
}

/* Toolbar */
.toolbar {
    padding: 1rem 2rem;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-form input[type="text"] {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 200px;
}

.search-form select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

.stats {
    color: #666;
    font-size: 0.9rem;
}

/* Main content layout */
.main-content {
    display: flex;
    min-height: calc(100vh - 140px);
}

/* Font list sidebar */
.font-list {
    width: 300px;
    background: #f9f9f9;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    max-height: calc(100vh - 140px);
}

.font-list h3 {
    padding: 1rem;
    background: #f0f0f0;
    margin: 0;
    font-size: 1rem;
    color: #555;
    border-bottom: 1px solid #e0e0e0;
}

.font-grid {
    padding: 0.5rem;
}

.font-item {
    margin-bottom: 0.5rem;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    position: relative;
}

.font-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.font-item.active {
    border: 2px solid #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.font-item a {
    display: flex;
    padding: 1rem;
    text-decoration: none;
    color: inherit;
}

.font-variant-item a {
    display: flex;
    align-items: center;
    flex: 1;
    text-decoration: none;
    color: inherit;
    padding-right: 5rem; /* Miejsce na przyciski akcji */
}

.font-preview {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: #f5f5f5;
    border-radius: 4px;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.font-info {
    flex: 1;
    min-width: 0;
}

.font-variant-info {
    flex: 1;
    margin-left: 0.5rem;
    min-width: 0; /* Zapobiega obcinaniu */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.font-variant-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    transition: background-color 0.2s;
    position: relative; /* Dodane dla absolutnego pozycjonowania przycisków */
}

.font-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.font-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #666;
}

.font-variant-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.1rem;
}

.font-variant-meta .weight {
    background: #fff3e0;
    color: #f57c00;
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
    font-size: 0.75rem;
}

.font-variant-meta .size {
    display: none;
}

.category {
    background: #e3f2fd;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    text-transform: capitalize;
}

.polish-badge {
    background: #4CAF50;
    color: white;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.7rem;
    cursor: help;
}

.polish-indicator {
    color: #4CAF50;
    font-weight: 500;
}

.no-polish-indicator {
    color: #666;
    font-weight: 500;
}

.polish-support {
    background: #e8f5e8;
    color: #2e7d2e;
    border: 1px solid #4CAF50;
}

.no-polish-support {
    background: #fff3e0;
    color: #f57c00;
    border: 1px solid #ff9800;
}

/* File upload enhancements */
.file-upload {
    position: relative;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.file-upload:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.file-upload.drag-over {
    border-color: #667eea;
    background: #f0f8ff;
    transform: scale(1.02);
}

.selected-files {
    margin-top: 15px;
    text-align: left;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin: 5px 0;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 0.9rem;
}

.file-item .file-name {
    font-weight: 500;
}

.file-item .file-size {
    color: #666;
    font-size: 0.8rem;
}

.file-item .remove-file {
    color: #f44336;
    cursor: pointer;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
}

.file-item .remove-file:hover {
    background: #f44336;
    color: white;
}

/* Progress bar for uploads */
.upload-progress {
    margin-top: 15px;
    display: none;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    width: 0%;
    transition: width 0.3s ease;
}

.upload-status {
    margin-top: 10px;
    font-size: 0.9rem;
}

.upload-results {
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.result-item {
    padding: 8px;
    margin: 5px 0;
    border-radius: 4px;
    font-size: 0.9rem;
}

.result-success {
    background: #e8f5e8;
    color: #2e7d2e;
    border-left: 4px solid #4CAF50;
}

.result-error {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #f44336;
}

.font-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10; /* Zapewnia, że przyciski są na wierzchu */
}

.font-item:hover .font-actions,
.font-variant-item:hover .font-actions {
    opacity: 1;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: #666;
}

.empty-state p {
    margin-bottom: 1rem;
}

/* Font viewer */
.font-viewer {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    max-height: calc(100vh - 140px);
}

.viewer-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.viewer-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.font-details {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: #666;
}

.font-details span {
    background: #f5f5f5;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.viewer-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* Character table */
.char-table h3,
.text-examples h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #333;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.char-controls {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 6px;
}

.char-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.char-controls input[type="range"] {
    flex: 1;
    max-width: 150px;
}

.char-section {
    margin-bottom: 2rem;
}

.char-section h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: #555;
}

.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 6px;
    margin-bottom: 1rem;
    justify-items: center;
}

.char {
    min-width: 44px;
    min-height: 44px;
    max-width: 100px;
    max-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
    box-sizing: border-box;
    overflow: hidden;
    text-align: center;
    line-height: 1;
}

.char:hover {
    background: #f0f8ff;
    border-color: #667eea;
    transform: scale(1.05);
    z-index: 10;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Responsive character grid */
@media (max-width: 768px) {
    .char-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
        gap: 4px;
    }

    .char {
        min-width: 45px;
        min-height: 45px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .char-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 3px;
    }

    .char {
        min-width: 40px;
        min-height: 40px;
        font-size: 16px;
    }
}

/* Text examples */
.text-controls {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 6px;
}

.text-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    cursor: pointer;
}

.text-sample {
    margin-bottom: 2rem;
    padding: 1rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.text-sample h4 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sample-text {
    line-height: 1.6;
    word-wrap: break-word;
    outline: none;
}

.sample-text[contenteditable="true"] {
    border: 2px dashed #667eea;
    padding: 0.5rem;
    border-radius: 4px;
}

.h1-sample {
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1.2;
}

.h2-sample {
    font-size: 2rem;
    font-weight: bold;
    line-height: 1.3;
}

.p-sample {
    font-size: 1rem;
    line-height: 1.6;
}

.polish-sample {
    font-size: 1.1rem;
    line-height: 1.5;
}

.alphabet-sample {
    font-size: 1.2rem;
    line-height: 1.8;
    letter-spacing: 1px;
}

/* No font selected state */
.no-font-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 50vh;
    text-align: center;
    color: #666;
}

.no-font-selected h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #999;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h2 {
    padding: 1.5rem 2rem 1rem;
    margin: 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 1.5rem;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close:hover {
    color: #000;
    background: #f0f0f0;
}

/* Form styles */
form {
    padding: 1.5rem 2rem 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="file"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.file-upload {
    position: relative;
}

.upload-info {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
    margin-top: 2rem;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Pagination */
.pagination {
    margin-top: 1rem;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 6px;
    border-top: 1px solid #e0e0e0;
}

.pagination-info {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pagination-controls .btn-small {
    min-width: 2rem;
    text-align: center;
}

.pagination-dots {
    color: #999;
    padding: 0 0.5rem;
    font-size: 1.2rem;
    line-height: 1;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination-controls {
        gap: 0.25rem;
    }
    
    .pagination-controls .btn-small {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
        min-width: 1.5rem;
    }
}