/* Base Layout */
body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f0f0f0;
    color: #222;
    padding: 24px;
    line-height: 1.5;
    margin: 0;
}

.container {
    max-width: 1000px;
    margin: 24px auto;
    background: #fff;
    padding: 24px;
    border: 1px solid #ccc;
}

/* Headings */
h1, h2, h3 {
    font-weight: bold;
    color: #111;
    margin-bottom: 16px;
}

h1 {
    font-size: 24px;
    border-bottom: 2px solid #333;
    padding-bottom: 8px;
}

h2 {
    font-size: 20px;
    border-bottom: 1px solid #ccc;
    padding-bottom: 6px;
    margin-top: 24px;
}

h3 {
    font-size: 16px;
    margin-top: 16px;
}

/* Text */
p {
    margin-bottom: 12px;
}

a {
    color: #0066cc;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: bold;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
input[type="number"],
select,
textarea {
    width: 100%;
    font-size: 13px;
    padding: 8px 10px;
    border: 1px solid #aaa;
    background: #fff;
    margin-bottom: 12px;
    box-sizing: border-box;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
    margin-right: 6px;
}

/* Buttons */
.btn,
button {
    font-size: 13px;
    padding: 8px 16px;
    border: 1px solid #666;
    background: #e0e0e0;
    color: #000;
    cursor: pointer;
    margin-right: 8px;
    margin-bottom: 8px;
    text-decoration: none;
    display: inline-block;
}

.btn:hover,
button:hover {
    background: #d0d0d0;
    text-decoration: none;
}

.btn-primary,
button.btn-primary {
    background: #0066cc;
    color: #fff;
    border-color: #0055aa;
}

.btn-primary:hover,
button.btn-primary:hover {
    background: #0055aa;
}

.btn-secondary {
    background: #666;
    color: #fff;
    border-color: #555;
}

.btn-secondary:hover {
    background: #555;
}

.btn-danger {
    background: #cc3333;
    color: #fff;
    border-color: #aa2222;
}

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

.btn-success {
    background: #339933;
    color: #fff;
    border-color: #227722;
}

.btn-success:hover {
    background: #227722;
}

.btn-small {
    padding: 4px 8px;
    font-size: 12px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 13px;
}

th, td {
    border: 1px solid #bbb;
    padding: 8px 10px;
    text-align: left;
}

th {
    background: #eee;
    font-weight: bold;
}

tr:nth-child(even) {
    background: #f9f9f9;
}

/* Alerts */
.warning,
.success,
.error,
.info {
    border: 1px solid #aaa;
    background: #f9f9f9;
    padding: 12px;
    margin: 16px 0;
    font-size: 13px;
}

.success {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.error {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

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

.info {
    background: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

/* Actions / Links */
.actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #ddd;
}

.links {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #ddd;
}

/* Dashboard specific */
.nav-menu {
    list-style: none;
    padding: 0;
    margin: 16px 0;
}

.nav-menu li {
    margin-bottom: 8px;
}

.nav-menu a {
    display: block;
    padding: 12px 16px;
    background: #f5f5f5;
    border: 1px solid #ccc;
    color: #333;
    text-decoration: none;
}

.nav-menu a:hover {
    background: #e8e8e8;
}

/* Login/Register specific */
.auth-container {
    max-width: 400px;
    margin: 40px auto;
}

.auth-container h2 {
    text-align: center;
}

/* Section boxes */
.section {
    border: 1px solid #ddd;
    padding: 16px;
    margin-bottom: 16px;
    background: #fafafa;
}

.section h3 {
    margin-top: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
}

/* Checkbox groups */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    font-size: 13px;
}

/* Stats boxes */
.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0;
}

.stat-box {
    padding: 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    min-width: 120px;
}

.stat-box strong {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.stat-box span {
    font-size: 18px;
    font-weight: bold;
}

/* User info */
.user-info {
    float: right;
    font-size: 13px;
    color: #666;
}

.user-info a {
    margin-left: 12px;
}

/* Template cards */
.template-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin: 16px 0;
}

.template-card {
    border: 1px solid #ddd;
    padding: 16px;
    background: #fff;
}

.template-card h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
}

.template-card p {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
}

.template-card .meta {
    font-size: 11px;
    color: #999;
    margin-bottom: 8px;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 13px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
}

/* Table wrapper for scrolling */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 450px;
    border: 1px solid #ddd;
    background: #fff;
}

.table-wrapper table {
    margin: 0;
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

.table-wrapper th {
    position: sticky;
    top: 0;
    background: #eee;
    z-index: 1;
}

.table-wrapper td,
.table-wrapper th {
    white-space: nowrap;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-wrapper td:hover {
    white-space: normal;
    overflow: visible;
    word-wrap: break-word;
}

/* Find/Replace rows */
.find-replace-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.find-replace-row input[type="text"] {
    width: 150px;
    margin-bottom: 0;
}

.find-replace-row select {
    width: 120px;
    margin-bottom: 0;
}

/* Format rows */
.format-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.format-row label {
    min-width: 100px;
    margin-bottom: 0;
}

.format-row select {
    width: 200px;
    margin-bottom: 0;
}

/* API Key display */
.api-key-display {
    font-family: monospace;
    background: #f5f5f5;
    padding: 10px;
    border: 1px solid #ddd;
    word-break: break-all;
    margin: 10px 0;
}

/* Audit log */
.audit-entry {
    padding: 8px;
    border-bottom: 1px solid #eee;
    font-size: 12px;
}

.audit-entry:nth-child(even) {
    background: #f9f9f9;
}

.audit-entry .time {
    color: #666;
    margin-right: 10px;
}

.audit-entry .action {
    font-weight: bold;
    color: #333;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid #ddd;
    margin-bottom: 16px;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -2px;
    background: #f5f5f5;
}

.tab:hover {
    background: #e8e8e8;
}

.tab.active {
    background: #fff;
    border-color: #ddd;
    border-bottom-color: #fff;
}

.tab-content {
    display: none;
}

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

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
    background: #666;
    color: #fff;
}

.badge-success {
    background: #28a745;
}

.badge-danger {
    background: #dc3545;
}

.badge-warning {
    background: #ffc107;
    color: #333;
}

/* Small screen tweaks */
@media (max-width: 640px) {
    body { padding: 16px; }
    .container { padding: 16px; margin: 16px auto; }
    table { font-size: 12px; }
    th, td { padding: 6px 8px; }
    .template-list { grid-template-columns: 1fr; }
    .stats { flex-direction: column; }
    .find-replace-row { flex-direction: column; align-items: stretch; }
    .find-replace-row input, .find-replace-row select { width: 100%; }
}
