/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #2c3e50;
    background-color: #f8f9fa;
    min-height: 100vh;
}

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

/* Header Styles */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
}

.search-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 1;
    max-width: 400px;
}

.search-input {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 25px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: rgba(255,255,255,0.7);
}

.search-input:focus {
    outline: none;
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.6);
}

/* Main Layout */
.main-container {
    display: flex;
    min-height: calc(100vh - 80px);
    gap: 0;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e9ecef;
    padding: 1.5rem;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-list {
    list-style: none;
    margin-top: 0.5rem;
}

.nav-list li {
    margin-bottom: 0.25rem;
}

.nav-list li.loading {
    color: #6c757d;
    font-style: italic;
    padding: 0.5rem 0;
}

.nav-list a {
    display: block;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: #495057;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.nav-list a:hover {
    background-color: #f8f9fa;
    color: #667eea;
}

.nav-list a.active {
    background-color: #667eea;
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Form Styles */
.form-section {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
}

.form-section h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.message-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

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

.form-group label {
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    font-family: inherit;
    color: #2c3e50;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea: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;
}

.translations-fieldset {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 0;
}

.translations-fieldset legend {
    padding: 0 0.5rem;
    font-weight: 600;
    color: #495057;
}

.translation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

/* Button Styles */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.btn-secondary:disabled,
.btn:disabled,
.sidebar .btn:disabled,
.sidebar .btn-secondary:disabled,
.sidebar .btn-primary:disabled,
.sidebar .btn-small:disabled {
    background: #FAFAFA !important;
    color: #000000 !important;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

/* Specific buttons that need disabled styling */
#newDomainBtn:disabled,
#newProjectBtn:disabled,
#newMessageBtn:disabled,
#clearSearchBtn:disabled {
    background: #FAFAFA !important;
    color: #000000 !important;
    cursor: not-allowed !important;
    transform: none !important;
    opacity: 0.6 !important;
}

/* Force sidebar buttons to show desired styling */
#newDomainBtn,
#newProjectBtn,
#clearSearchBtn,
#exportBtn,
#newMessageBtn {
    background: #FAFAFA !important;
    color: #000000 !important;
}

.btn-accent {
    background: #28a745;
    color: white;
}

.btn-accent:hover {
    background: #218838;
    transform: translateY(-1px);
}

.btn-accent:disabled {
    background: #FAFAFA !important;
    color: #000000 !important;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-text {
    background: none;
    color: #6c757d;
    padding: 0.5rem;
}

.btn-text:hover {
    color: #495057;
}

.btn-text:disabled {
    background: #FAFAFA !important;
    color: #000000 !important;
    cursor: not-allowed;
    opacity: 0.6;
}

/* List Styles */
.list-section {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.list-header {
    margin-bottom: 1.5rem;
}

.list-header h2 {
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 1.5rem 0;
}

/* Search Form */
.search-form {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.search-row {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr auto;
    gap: 1rem;
    align-items: end;
}

.search-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.search-field label {
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.search-select,
.search-input {
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
    font-family: inherit;
    background: white;
    color: #2c3e50;
}

.search-select:focus,
.search-input:focus {
    outline: none;
    border-color: #667eea;
}

.search-select:disabled,
.search-input:disabled {
    background: #FAFAFA !important;
    color: #000000 !important;
    cursor: not-allowed;
    opacity: 0.6;
    border-color: #e9ecef;
}

.search-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.advanced-search {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.list-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.list-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.view-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
}

.view-toggle .btn.active {
    background: #667eea;
    color: white;
}

.view-toggle .btn:disabled {
    background: #FAFAFA !important;
    color: #000000 !important;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.filter-select {
    padding: 0.5rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
}

.filter-select:disabled {
    background: #FAFAFA !important;
    color: #000000 !important;
    cursor: not-allowed;
    opacity: 0.6;
}

.messages-container {
    min-height: 200px;
}

.message-item {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid #667eea;
    transition: all 0.2s ease;
}

.message-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.message-code {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.1rem;
    color: #667eea;
}

.message-badges {
    display: flex;
    gap: 0.5rem;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.badge.type-nt { background: #e3f2fd; color: #1976d2; }
.badge.type-me { background: #f3e5f5; color: #7b1fa2; }
.badge.reason-su { background: #e8f5e8; color: #2e7d32; }
.badge.reason-al { background: #fff3e0; color: #f57c00; }
.badge.reason-er { background: #ffebee; color: #d32f2f; }
.badge.reason-in { background: #e0f2f1; color: #00695c; }

.message-content {
    margin-bottom: 1rem;
}

.message-acronym {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
}

.message-description {
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.message-translations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #dee2e6;
}

.translation-item {
    padding: 0.5rem;
    background: white;
    border-radius: 4px;
    font-size: 0.85rem;
}

.translation-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.message-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-mini {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.btn-mini:disabled {
    background: #FAFAFA !important;
    color: #000000 !important;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

/* Messages Table */
.messages-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.messages-table th,
.messages-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.messages-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.messages-table tr:hover {
    background-color: #f8f9fa;
}

.messages-table .code-cell {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #667eea;
}

.messages-table .project-cell {
    color: #495057;
}

.messages-table .message-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.messages-table .translations-cell {
    text-align: center;
}

.messages-table .actions-cell {
    white-space: nowrap;
}

.translation-count {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: #e3f2fd;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #1976d2;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.pagination-info {
    color: #6c757d;
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-jump {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-jump input {
    width: 120px;
    padding: 0.4rem 0.6rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #2c3e50;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.modal-large {
    max-width: 800px;
}

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

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid #e9ecef;
}

.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.radio-group label,
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
}

.export-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.export-preview pre {
    margin: 0;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-left: 4px solid #28a745;
    max-width: 350px;
    animation: slideIn 0.3s ease;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast.warning {
    border-left-color: #ffc107;
    color: #856404;
}

.toast.success {
    border-left-color: #28a745;
    color: #155724;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Utility Classes */
.hidden {
    display: none !important;
}

.loading {
    color: #6c757d;
    font-style: italic;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        order: 2;
        max-height: 300px;
        border-right: none;
        border-top: 1px solid #e9ecef;
    }

    .main-content {
        order: 1;
        padding: 1rem;
    }

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

    .search-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .search-actions {
        justify-content: flex-end;
    }

    .list-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .view-controls {
        width: 100%;
        justify-content: space-between;
    }

    .message-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .message-translations {
        grid-template-columns: 1fr;
    }

    .form-actions {
        justify-content: center;
    }

    .modal-content {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    .messages-table {
        font-size: 0.8rem;
    }

    .messages-table th,
    .messages-table td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .header .container {
        flex-direction: column;
        text-align: center;
    }

    .form-section,
    .list-section {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 8px;
    }

    .sidebar {
        padding: 1rem;
    }

    .message-item {
        padding: 1rem;
    }
}