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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    font-size: 1.8rem;
}

nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.btn-primary:hover {
    background-color: #218838;
}

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

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-nav {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-nav:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 4px;
}

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

.btn-danger:hover {
    background-color: #c82333;
}

.btn-view {
    background-color: #17a2b8;
    color: white;
}

.btn-view:hover {
    background-color: #138496;
}

.btn-edit {
    background-color: #ffc107;
    color: #212529;
}

.btn-edit:hover {
    background-color: #e0a800;
}

.btn-delete {
    background-color: #dc3545;
    color: white;
}

.btn-delete:hover {
    background-color: #c82333;
}

/* Main Content */
main {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

h2 {
    margin-bottom: 20px;
    color: #444;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

/* List page header: title left, primary action right.
   Keeps the "add" button consistently ABOVE the table on every list page. */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.list-header h2 {
    margin-bottom: 0;
    flex: 1 1 auto;
}

.list-header .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 20px;
}

.alert {
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Table */

.inline-form {
    display: inline;
}

/* Margin Colors */
.margin-positive {
    color: #28a745;
    font-weight: 600;
}

.margin-negative {
    color: #dc3545;
    font-weight: 600;
}

.margin-zero {
    color: #6c757d;
}

.margin-badge {
    font-size: 0.75rem;
    background-color: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state a {
    color: #667eea;
    text-decoration: none;
}

.empty-state a:hover {
    text-decoration: underline;
}

/* Form */
.form {
    max-width: 500px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.margin-preview {
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #6c757d;
    border: 2px dashed #ddd;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
    flex-wrap: wrap;
}

/* Detail Card */
.detail-card {
    max-width: 500px;
    background-color: #f8f9fa;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 25px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #dee2e6;
}

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

.detail-label {
    font-weight: 600;
    color: #666;
}

.detail-value {
    color: #333;
}

/* Category Badge */
.category-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    background-color: #667eea;
    color: white;
}

/* Form Select & Textarea */
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
    background-color: white;
}

.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

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

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    margin-top: 20px;
}

/* Login Info Section */
.login-info {
    max-width: 400px;
    margin: 30px auto;
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    border: 1px solid #dee2e6;
}
.login-info h3 {
    margin-bottom: 15px;
    color: #444;
    font-size: 1.1rem;
}
.login-info p {
    margin-bottom: 10px;
    color: #555;
}
.login-info .data-table {
    margin: 15px 0;
}
.login-info .data-table th,
.login-info .data-table td {
    padding: 8px 12px;
    font-size: 0.9rem;
}
.login-info-note {
    font-size: 0.85rem;
    color: #856404;
    background: #fff3cd;
    padding: 10px 15px;
    border-radius: 6px;
    border: 1px solid #ffc107;
    margin-top: 15px;
}

/* Enhanced Data Table Styling */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 10px;
}
.data-table thead th {
    background-color: #E0F2FE;
    color: #0C4A6E;
    font-weight: 600;
    padding: 14px 18px;
    border-bottom: 1px solid #BAE6FD;
    text-align: left;
    letter-spacing: 0.01em;
}
.data-table tbody tr:nth-child(even) {
    background-color: #F8FAFC;
}
.data-table tbody tr:hover {
    background-color: #EFF6FF;
    transition: background-color 0.2s ease;
}
.data-table tbody td {
    padding: 12px 18px;
    border-bottom: 1px solid #E2E8F0;
    text-align: left;
    color: #1E293B;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}
.data-table .numeric {
    text-align: right;
    font-family: 'Courier New', monospace;
}
.data-table .actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        text-align: center;
    }

    .data-table {
        font-size: 0.85rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .data-table .actions {
        flex-direction: column;
    }

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

    .btn {
        width: 100%;
    }
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.user-info span {
    opacity: 0.9;
}

/* Login Form */
.form-login {
    max-width: 400px;
    margin: 40px auto;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.form-login .form-group {
    margin-bottom: 20px;
}

.form-login label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-login input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.form-login .btn {
    width: 100%;
    margin-top: 10px;
}

/* Table Permissions */
.table-perms input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: #667eea;
}
.table-perms td {
    text-align: center;
}
.table-perms td:first-child {
    text-align: left;
}
.table-perms input[type="checkbox"]:hover {
    transform: scale(1.15);
    transition: transform 0.15s ease;
}

/* Error Page */
.error-page {
    max-width: 560px;
    margin: 60px auto;
    background: white;
    padding: 48px 32px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.error-code {
    font-size: 5rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 16px;
}

.error-page h1 {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 12px;
}

.error-page p {
    color: #6c757d;
    margin-bottom: 28px;
}

/* Login Info Card */
.login-info-card {
    max-width: 480px;
    margin: 0 auto 30px;
    background: white;
    padding: 28px 32px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.login-info-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.login-info-card .description {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    text-align: left;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.feature-item .icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.feature-item .feature-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.feature-item .feature-desc {
    font-size: 0.78rem;
    color: #666;
    line-height: 1.4;
}

@media (max-width: 480px) {
    .feature-grid {
        grid-template-columns: 1fr;
    }

    .login-info-card {
        padding: 20px;
    }
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background-color: #d4edda;
    color: #155724;
}

.badge-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.badge-warning {
    background-color: #fff3cd;
    color: #856404;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px 20px;
    text-align: center;
}

.summary-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.summary-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #333;
}
