/* EQ Tradeskill Planner - Stylesheet */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2c5f2d;
    --primary-light: #4a8b4c;
    --secondary: #1a3a1a;
    --accent: #c4a35a;
    --bg: #f5f0e8;
    --bg-dark: #e8e0d0;
    --text: #2d2d2d;
    --text-light: #666;
    --white: #fff;
    --danger: #c0392b;
    --warning: #f39c12;
    --success: #27ae60;
    --info: #2980b9;
    --border: #ccc;
    --radius: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

/* Navbar */
.navbar {
    background: var(--secondary);
    color: var(--white);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.navbar-brand {
    color: var(--accent);
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: bold;
}

.navbar-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.navbar-links a {
    color: var(--white);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.navbar-links a:hover {
    background: var(--primary);
}

.navbar-links .admin-link {
    color: var(--accent);
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Main */
main {
    flex: 1;
    padding: 1.5rem 1rem;
}

/* Footer */
.footer {
    background: var(--secondary);
    color: var(--text-light);
    text-align: center;
    padding: 1rem 0;
    font-size: 0.85rem;
    margin-top: auto;
}

.footer-version {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 0.25rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.alert-success {
    background: #d4edda;
    border-color: var(--success);
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border-color: var(--danger);
    color: #721c24;
}

.alert-info {
    background: #d1ecf1;
    border-color: var(--info);
    color: #0c5460;
}

.alert-warning {
    background: #fff3cd;
    border-color: var(--warning);
    color: #856404;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--bg-dark);
    color: var(--primary);
}

/* Grid */
.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s, transform 0.1s;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--primary);
    color: var(--white);
}
.btn-primary:hover { background: var(--primary-light); }

.btn-secondary {
    background: var(--bg-dark);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(44, 95, 45, 0.2);
}

select.form-control {
    appearance: auto;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--bg-dark);
}

th {
    background: var(--secondary);
    color: var(--white);
    font-weight: 600;
    position: sticky;
    top: 0;
}

tr:hover {
    background: var(--bg-dark);
}

/* Progress Bar */
.progress-bar {
    background: var(--bg-dark);
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    margin: 0.25rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 10px;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 2rem;
}

/* Tier badges */
.tier-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--white);
}

.tier-book { background: var(--success); }
.tier-vendor { background: var(--info); }
.tier-inventory { background: #8e44ad; }
.tier-mixed { background: #2c3e50; }
.tier-common { background: var(--warning); color: var(--text); }
.tier-farm { background: #e67e22; }
.tier-complex { background: var(--danger); }
.tier-nodata { background: #888; }

/* Tier filter toggle buttons */
.tier-toggle {
    cursor: pointer;
    border: 2px solid transparent;
    transition: opacity 0.2s, border-color 0.2s;
    user-select: none;
}

.tier-toggle:hover {
    border-color: rgba(0, 0, 0, 0.3);
}

.tier-toggle.tier-off {
    opacity: 0.35;
    border-color: var(--border);
    text-decoration: line-through;
}

/* NODROP badge */
.badge-nodrop {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: var(--danger);
    color: var(--white);
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: bold;
}

/* TOOL badge (returned/not consumed) */
.badge-tool {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: #fef9e7;
    color: #9a7d0a;
    border: 1px solid #f9e79f;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: bold;
}

/* Source badges */
.badge-source {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: bold;
}

.badge-vendor { background: #d5f5e3; color: #1e8449; }
.badge-drop { background: #fadbd8; color: #922b21; }
.badge-quest { background: #d6eaf8; color: #1f618d; }
.badge-foraged { background: #fdebd0; color: #af601a; }
.badge-ground_spawn { background: #f9e79f; color: #7d6608; }
.badge-fish { background: #d1f2eb; color: #148f77; }
.badge-unknown { background: #eee; color: #666; }

/* File Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--bg-dark);
}

.upload-area input[type="file"] {
    display: none;
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Stats grid */
.stat-card {
    text-align: center;
    padding: 1rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Recipe tree */
.recipe-tree {
    padding-left: 1.5rem;
    border-left: 2px solid var(--bg-dark);
    margin-left: 0.5rem;
}

.recipe-tree-item {
    padding: 0.25rem 0;
}

/* Checkbox list */
.recipe-select-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
}

.recipe-select-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
}

.recipe-select-item:hover {
    background: var(--bg-dark);
}

.recipe-select-item input[type="checkbox"] {
    flex-shrink: 0;
}

/* Selection toolbar */
.selection-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-dark);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.selection-count {
    font-weight: bold;
    margin-right: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .navbar-toggle {
        display: block;
    }

    .navbar-links {
        display: none;
        width: 100%;
        flex-direction: column;
        padding-top: 0.5rem;
    }

    .navbar-links.open {
        display: flex;
    }

    .navbar-links a {
        padding: 0.5rem;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 0.35rem 0.5rem;
    }
}

/* Admin specific */
.admin-header {
    background: var(--accent);
    color: var(--secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-weight: bold;
}

/* Tab navigation */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--bg-dark);
    margin-bottom: 1rem;
}

.tab {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
}

.pagination a:hover {
    background: var(--bg-dark);
}

.pagination .active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

#recipe-pag-top, #shopping-pag-top {
    margin-bottom: 0.5rem;
}

#recipe-pag-bottom, #shopping-pag-bottom {
    margin-top: 0.5rem;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-text {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Shopping list tree */
.shopping-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.shopping-item {
    border: 1px solid var(--bg-dark);
    border-radius: var(--radius);
    overflow: hidden;
}

.shopping-item[open] {
    border-color: var(--primary-light);
}

.shopping-item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    background: var(--bg);
    font-size: 0.9rem;
    list-style: none;
    user-select: none;
}

.shopping-item-header::-webkit-details-marker {
    display: none;
}

.shopping-item-header::before {
    content: '\25b6';
    font-size: 0.6rem;
    color: var(--text-light);
    transition: transform 0.15s;
    flex-shrink: 0;
}

.shopping-item[open] > .shopping-item-header::before {
    transform: rotate(90deg);
}

.shopping-item-header:hover {
    background: var(--bg-dark);
}

.shopping-item-name {
    font-weight: 600;
    white-space: nowrap;
}

.shopping-item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    font-size: 0.85rem;
    white-space: nowrap;
}

.shopping-qty {
    color: var(--text-light);
}

.shopping-item-details {
    padding: 0.5rem 0.75rem 0.75rem 1.75rem;
    border-top: 1px solid var(--bg-dark);
    background: var(--white);
    font-size: 0.85rem;
}

.shopping-sources {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.shopping-source-entry {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0;
}

.shopping-zone {
    color: var(--text-light);
    font-style: italic;
}
