/* CSS Variables for color consistency */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #3a3a3a;
    --bg-quaternary: #4a4a4a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #707070;
    --border-primary: #3a3a3a;
    --border-secondary: #4a4a4a;
    --link-color: #4dd0e1;
    --code-color: #ff7f50;
    --radius-outer: 5px;
    --radius-inner: 3px;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-primary: #ffffff;
        --bg-secondary: #f9f9f9;
        --bg-tertiary: #e9ecef;
        --bg-quaternary: #dee2e6;
        --text-primary: #333333;
        --text-secondary: #6c757d;
        --text-muted: #6c757d;
        --border-primary: #dee2e6;
        --border-secondary: #adb5bd;
        --link-color: #007bff;
        --code-color: #d63384;
    }
}

/* Base styles */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: "Inter var", "system-ui", "Roboto", "Arial", sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* Layout */
.container {
    margin: 0 auto;
    padding: 20px;
}

.container-sm {
    max-width: 800px !important;
}

.content {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-outer);
    padding: 30px;
}

/* Navigation */
.navbar {
    display: flex;
    justify-content: flex-end;
    padding: 20px 0;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 16px;
}

.nav-link:hover {
    color: #ffffff;
}

/* Profile section */
.profile {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
}

.profile-image {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 25px;
}

.profile-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.profile-info h1 {
    font-size: 28px;
    margin: 0 0 10px 0;
}

.profile-info p {
    font-size: 16px;
    margin: 0 0 10px 0;
}

.social-icons {
    font-size: 18px;
}

.social-icons a {
    color: var(--text-primary);
    margin-right: 15px;
    text-decoration: none;
}

.social-icons a:hover {
    color: #ffffff;
}

/* Typography */
h2 { font-size: 24px; margin-bottom: 20px; }
h3 { font-size: 20px; margin-bottom: 16px; }
h5 { font-size: 18px; margin-bottom: 12px; font-weight: 500; }
p { font-size: 16px; }

/* Common elements */
img { max-width: 100%; }
a { color: var(--link-color); }
code { 
    color: var(--code-color);
    background-color: var(--bg-tertiary);
    padding: 0.2em 0.4em;
    border-radius: var(--radius-inner);
}

.header-anchor { text-decoration: none; }

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    display: table;
}

th, td {
    border: 2px solid white;
    padding: 8px;
    text-align: left;
    word-break: break-all;
}

@media (prefers-color-scheme: light) {
    th, td {
        border: 1px solid var(--border-primary);
    }
}

/* Post lists */
.post-list { display: table; }
.post-list-item { display: table-row; }
.post-date {
    display: table-cell;
    padding-right: 1em;
    white-space: nowrap;
    width: 7em;
    min-width: 7em;
}
.post-link { display: table-cell; }

ul {
    list-style: none;
    padding-left: 0px;
}

blockquote p { margin: 0; }

/* Forms */
input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.5rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    border-radius: 0;
    font-family: inherit;
    font-size: 16px;
    margin-bottom: 1rem;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--border-secondary);
    background-color: var(--bg-tertiary);
}

/* File input */
input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    margin-bottom: 1rem;
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    padding: 0.25rem 0.75rem;
    margin-right: 0.5rem;
    cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
    background-color: var(--bg-quaternary);
}

/* Drag and drop */
.file-drop-area {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 3rem 2rem;
    background-color: var(--bg-tertiary);
    border: 2px dashed var(--border-primary);
    border-radius: var(--radius-inner);
    margin-bottom: 1rem;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s ease;
}

.file-drop-area:hover {
    border-color: var(--border-secondary);
}

.file-drop-area.drag-over {
    border-color: var(--border-secondary);
    background-color: var(--bg-quaternary);
}

.file-drop-area input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    opacity: 0;
    margin: 0;
}

.file-drop-text {
    color: var(--text-secondary);
    font-size: 16px;
    pointer-events: none;
}

.file-drop-text .file-name {
    color: var(--text-primary);
    font-weight: 500;
    display: block;
    margin-top: 0.5rem;
}

/* Buttons */
button,
input[type="submit"] {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    margin-right: 1rem;
    border-radius: var(--radius-inner);
}

button:hover,
input[type="submit"]:hover {
    background-color: var(--bg-quaternary);
    color: #ffffff;
}

/* Progress bar */
progress {
    width: 100%;
    height: 20px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    -webkit-appearance: none;
    appearance: none;
    border-radius: var(--radius-inner);
    overflow: hidden;
}

progress::-webkit-progress-bar {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-inner);
}

progress::-webkit-progress-value {
    background-color: var(--bg-quaternary);
    border-radius: var(--radius-inner);
}

progress::-moz-progress-bar {
    background-color: var(--bg-quaternary);
    border-radius: var(--radius-inner);
}

/* Code blocks */
pre {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-inner);
    padding: 1rem;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 400px;
    color: var(--text-primary);
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.4;
}

/* Admin Panel */
.admin-container { 
    min-height: 100vh; 
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.admin-sidebar {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem 1rem;
    position: fixed;
    width: 250px;
    left: 0;
    top: 0;
    border-right: 1px solid var(--border-primary);
}

.admin-sidebar h4 {
    color: var(--text-primary);
    margin-bottom: 2rem;
    font-size: 1.5rem;
    font-weight: normal;
}

.admin-sidebar .nav-link {
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.75rem 1rem;
    display: block;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.3s;
}

.admin-sidebar .nav-link:hover {
    background-color: var(--bg-quaternary);
    color: #ffffff;
}

.admin-sidebar .nav-link.active {
    background-color: var(--bg-quaternary);
    color: #ffffff;
}

.admin-sidebar .nav-link.text-danger {
    color: #ff6b6b;
}

.admin-sidebar .nav-link.text-danger:hover {
    background-color: var(--bg-quaternary);
    color: #ff8787;
}

.admin-content {
    margin-left: 250px;
    padding: 2rem;
    background-color: var(--bg-primary);
}

.admin-header {
    background-color: var(--bg-tertiary);
    padding: 2rem;
    border-radius: var(--radius-outer);
    margin-bottom: 2rem;
}

.admin-header h1 {
    color: var(--text-primary);
    font-size: 28px;
    margin: 0 0 0.5rem 0;
    font-weight: normal;
}

.admin-header p {
    color: var(--text-secondary);
    margin: 0;
}

/* Cards */
.stats-card,
.plant-card,
.package-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.stats-card h3,
.plant-card h3,
.package-card h3 {
    color: var(--text-primary);
    font-size: 20px;
    margin-bottom: 0.5rem;
}

.stats-card p,
.plant-card p,
.package-card p {
    color: var(--text-secondary);
    margin: 0.5rem 0;
}

/* Desktop hover effects */
@media (hover: hover) and (pointer: fine) {
    .plant-card:hover,
    .package-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
        border-color: var(--border-primary);
    }
}

/* Plant specific text colors */
.plant-card .text-muted.small {
    color: #ffffff !important;
}

/* Plant delete button */
.btn-icon-delete {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff6b6b;
    opacity: 0;
    transition: all 0.2s ease;
    cursor: pointer;
    position: absolute;
    bottom: 1rem;
    right: 1rem;
}

.btn-icon-delete i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Desktop hover effects for delete button */
@media (hover: hover) and (pointer: fine) {
    .plant-card:hover .btn-icon-delete {
        opacity: 1;
    }
}

/* Always show delete button on mobile */
@media (hover: none) and (pointer: coarse) {
    .btn-icon-delete {
        opacity: 1;
    }
}

.btn-icon-delete:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

/* Grids */
.plant-grid,
.package-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

/* Plant specific */
.plant-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--plant-color, #2d6a4f);
}

/* Status badges */
.plant-status,
.package-status {
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-healthy { background-color: rgba(52, 211, 153, 0.1); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.3); }
.status-warning { background-color: rgba(251, 191, 36, 0.1); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.3); }
.status-critical { background-color: rgba(248, 113, 113, 0.1); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.3); }
.status-delivered { background-color: rgba(34, 197, 94, 0.1); color: #22c55e; }
.status-transit { background-color: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.status-pickup { background-color: rgba(168, 85, 247, 0.1); color: #a855f7; }
.status-pending { background-color: rgba(251, 191, 36, 0.1); color: #fbbf24; }
.status-expired { background-color: rgba(107, 114, 128, 0.1); color: #6b7280; }
.status-exception { background-color: rgba(239, 68, 68, 0.1); color: #ef4444; }

/* Utility classes */
.mt-3 { margin-top: 1rem; }
.text-muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }
.list-unstyled { list-style: none; padding-left: 0; margin: 0; }
.sidebar-divider { border-top: 1px solid var(--border-primary); margin: 2rem 0; }

/* Hamburger menu */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: 0.25rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.hamburger-btn:hover {
    background-color: var(--bg-quaternary);
    color: #ffffff;
}

/* Mobile styles */
@media screen and (max-width: 640px) {
    .post-date,
    .post-link,
    .post-list-item,
    .post-list { display: block; }
    
    .post-date { padding-right: 1em; }
    .post-list { width: 100%; }
    
    .content { border-radius: 0; padding: 10px 1rem; }
    .container { padding: 10px; }
    .container-sm { max-width: 100% !important; padding: 0; }
    
    .profile {
        align-items: flex-start;
        margin-bottom: 20px;
        padding-left: 15px;
        padding-top: 15px;
    }
    
    .profile-image {
        width: 100px;
        height: 100px;
        margin-right: 15px;
    }
    
    .profile-info h1 { font-size: 24px; }
    .profile-info p { font-size: 14px; }
    
    .navbar { padding-right: 15px; }
}

/* Mobile admin */
@media screen and (max-width: 768px) {
    .hamburger-btn { display: block; }
    
    .admin-sidebar {
        position: fixed;
        top: 0;
        left: -250px;
        width: 250px;
        transition: left 0.1s ease;
        z-index: 1000;
    }
    
    .admin-sidebar.sidebar-open { left: 0; }
    
    .admin-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 5rem;
    }
    
    .admin-header { padding: 1rem; }
    .admin-header h1 { font-size: 24px; }
    
    .plant-grid,
    .package-grid,
    .analytics-grid { grid-template-columns: 1fr; }
    
    .plant-card,
    .stats-card { padding: 1rem; }
}

/* Light mode specific overrides */
@media (prefers-color-scheme: light) {
    .admin-sidebar .nav-link:hover { background-color: var(--bg-quaternary); color: #333333; }
    .admin-sidebar .nav-link.active { background-color: #007bff; color: #ffffff; }
    .admin-sidebar .nav-link.text-danger { color: #dc3545; }
    .admin-sidebar .nav-link.text-danger:hover { background-color: #fee; color: #c92a2a; }
    
    .status-healthy { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
    .status-warning { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
    .status-critical { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
    .status-delivered { background-color: #d4edda; color: #155724; }
    .status-transit { background-color: #cce5ff; color: #004085; }
    .status-pickup { background-color: #e7d6ff; color: #4b2c6f; }
    .status-pending { background-color: #fff3cd; color: #856404; }
    .status-expired { background-color: #e2e3e5; color: #383d41; }
    .status-exception { background-color: #f8d7da; color: #721c24; }
    
    /* Delete button light mode */
    .btn-icon-delete {
        background-color: #f8d7da;
        color: #721c24;
        border-color: #f5c6cb;
    }
    
    .btn-icon-delete:hover {
        background-color: #f5c6cb;
        color: #491217;
        border-color: #f1b0b7;
    }
}

/* Chart tooltip */
.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    padding: 0.5rem;
    font-size: 0.875rem;
    font-family: monospace;
    color: var(--text-primary);
    z-index: 1000;
    display: none;
}

.chart-tooltip.visible {
    display: block;
}

/* Footnote styles */
.footnote-ref {
    text-decoration: none;
    font-weight: 600;
}

.footnote-ref:hover {
    text-decoration: underline;
}

/* Footnote tooltip */
.footnote-tooltip {
    position: absolute;
    z-index: 1000;
    max-width: 400px;
    padding: 12px 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-inner);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.footnote-tooltip.visible {
    opacity: 1;
    pointer-events: auto;
}

.footnote-tooltip p {
    margin: 0;
    font-size: 14px;
}

.footnote-tooltip a {
    color: var(--link-color);
}

/* Hide back reference link in tooltip */
.footnote-tooltip .footnote-backref {
    display: none;
}

/* Mobile adjustments for footnote tooltip */
@media screen and (max-width: 640px) {
    .footnote-tooltip {
        max-width: 90vw;
        left: 5vw !important;
        right: 5vw !important;
        width: auto;
    }
}
