/**
 * SPS Garden & Production Module Styles
 */

/* Main Layout */
.garden-main {
    padding: 20px 0;
    min-height: calc(100vh - 80px);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header-left {
    flex: 1;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: var(--text-primary, #1a1a2e);
}

.page-subtitle {
    color: var(--text-secondary, #6b7280);
    margin: 0;
}

.page-header-right {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

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

.stat-card {
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color, #e5e7eb);
}

.stat-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.stat-icon-green { background: rgba(39, 174, 96, 0.1); }
.stat-icon-blue { background: rgba(52, 152, 219, 0.1); }
.stat-icon-orange { background: rgba(243, 156, 18, 0.1); }
.stat-icon-purple { background: rgba(155, 89, 182, 0.1); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color, #e5e7eb);
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary, #1a1a2e);
}

.tab-btn.active {
    color: var(--primary-color, #3b82f6);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color, #3b82f6);
}

.tab-content {
    display: none;
}

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

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar select,
.filter-bar input[type="text"],
.filter-bar input[type="date"] {
    padding: 8px 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--card-bg, #ffffff);
    color: var(--text-primary, #1a1a2e);
}

.filter-bar select:focus,
.filter-bar input:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
}

/* Gardens Grid */
.gardens-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.garden-card {
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color, #e5e7eb);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.garden-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.garden-card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.garden-type-badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    background: var(--primary-light, #e0f2fe);
    color: var(--primary-color, #3b82f6);
    border-radius: 4px;
    text-transform: capitalize;
}

.garden-card-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 12px;
}

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

.garden-stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
}

.garden-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
}

.garden-area,
.garden-zone {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 4px;
}

.garden-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

/* Plant Guides Grid */
.guides-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.guide-card {
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color, #e5e7eb);
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.guide-card.builtin {
    border-left: 3px solid var(--primary-color, #3b82f6);
}

.guide-card.user {
    border-left: 3px solid #27ae60;
}

.guide-card-header h4 {
    margin: 0 0 4px 0;
    font-size: 1rem;
}

.guide-card-header .latin-name {
    font-style: italic;
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
}

.guide-variety {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 8px;
}

.guide-info {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
}

.guide-category {
    background: var(--bg-secondary, #f3f4f6);
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: capitalize;
}

.guide-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.guide-badge.builtin {
    background: var(--primary-light, #e0f2fe);
    color: var(--primary-color, #3b82f6);
}

.guide-badge.user {
    background: #d5f5e3;
    color: #27ae60;
}

/* Data Table */
.plants-table-container,
.harvests-table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    background: var(--bg-secondary, #f9fafb);
}

.data-table tbody tr:hover {
    background: var(--bg-secondary, #f9fafb);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-planned { background: #e0e7ff; color: #4338ca; }
.status-seeded { background: #fef3c7; color: #92400e; }
.status-germinated { background: #d1fae5; color: #065f46; }
.status-growing { background: #d1fae5; color: #065f46; }
.status-flowering { background: #fce7f3; color: #9d174d; }
.status-fruiting { background: #fed7aa; color: #9a3412; }
.status-harvested { background: #dbeafe; color: #1e40af; }
.status-failed { background: #fee2e2; color: #991b1b; }

/* Logs List */
.logs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.log-entry {
    background: var(--card-bg, #ffffff);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color, #e5e7eb);
}

.log-header {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.log-date {
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
}

.log-action {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.action-planted { background: #d1fae5; color: #065f46; }
.action-watered { background: #dbeafe; color: #1e40af; }
.action-fertilized { background: #fef3c7; color: #92400e; }
.action-pruned { background: #e0e7ff; color: #4338ca; }
.action-weeded { background: #f3e8ff; color: #7c3aed; }
.action-pest_treatment { background: #fee2e2; color: #991b1b; }
.action-disease_treatment { background: #fee2e2; color: #991b1b; }
.action-germination { background: #d1fae5; color: #065f46; }
.action-flowering { background: #fce7f3; color: #9d174d; }
.action-fruiting { background: #fed7aa; color: #9a3412; }
.action-harvested { background: #dbeafe; color: #1e40af; }
.action-observation { background: #f3f4f6; color: #374151; }
.action-weather { background: #e0f2fe; color: #0369a1; }
.action-other { background: #f3f4f6; color: #374151; }

.log-garden,
.log-plant {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
}

.log-content {
    color: var(--text-primary, #1a1a2e);
    line-height: 1.5;
}

.log-weather {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 8px;
}

.log-gdd {
    font-size: 0.75rem;
    color: var(--primary-color, #3b82f6);
    margin-top: 4px;
}

.log-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

/* Harvest Summary */
.harvest-summary-stats {
    display: flex;
    gap: 32px;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 12px;
}

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

.summary-stat .value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
}

.summary-stat .label {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
}

/* Environment */
.environment-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.chart-container {
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color, #e5e7eb);
    height: 300px;
}

.env-summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 16px;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 8px;
}

.env-stat {
    display: flex;
    gap: 8px;
}

.env-stat .label {
    color: var(--text-secondary, #6b7280);
}

.env-stat .value {
    font-weight: 600;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg, #ffffff);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-content.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary, #6b7280);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary, #1a1a2e);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 20px;
}

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

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary, #1a1a2e);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--card-bg, #ffffff);
    color: var(--text-primary, #1a1a2e);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.form-group label:has(input[type="checkbox"]) {
    flex-direction: row;
    align-items: center;
}

/* Guide Modal Tabs */
.guide-tabs {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    overflow-x: auto;
}

.guide-tab-btn {
    padding: 12px 16px;
    background: none;
    border: none;
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.guide-tab-btn:hover {
    color: var(--text-primary, #1a1a2e);
}

.guide-tab-btn.active {
    color: var(--primary-color, #3b82f6);
}

.guide-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color, #3b82f6);
}

.guide-tab-content {
    display: none;
}

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

/* Garden Detail Modal */
.garden-detail-tabs {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: var(--bg-secondary, #f9fafb);
}

.detail-tab-btn {
    padding: 12px 16px;
    background: none;
    border: none;
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    position: relative;
}

.detail-tab-btn:hover {
    color: var(--text-primary, #1a1a2e);
}

.detail-tab-btn.active {
    color: var(--primary-color, #3b82f6);
    background: var(--card-bg, #ffffff);
    border-radius: 8px 8px 0 0;
}

.detail-tab-content {
    display: none;
    padding: 20px;
}

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

/* Garden Overview */
.garden-overview {
    padding: 16px;
}

.overview-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.info-row {
    display: flex;
    gap: 8px;
}

.info-row .label {
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
}

.overview-description {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-secondary, #6b7280);
}

/* Beds Grid */
.beds-toolbar {
    margin-bottom: 16px;
}

.beds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.bed-card {
    background: var(--bg-secondary, #f9fafb);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color, #e5e7eb);
}

.bed-card h4 {
    margin: 0 0 8px 0;
}

.bed-info {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 12px;
}

.bed-actions {
    display: flex;
    gap: 8px;
}

/* Stats in Garden Detail */
.stats-overview {
    display: flex;
    gap: 32px;
    margin-bottom: 24px;
}

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

.stat-item .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-item .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
}

.top-plants-list {
    margin: 0;
    padding-left: 20px;
}

.top-plants-list li {
    margin-bottom: 8px;
}

/* Guide View */
.guide-view-content {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.guide-view-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.guide-section h4 {
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.guide-section .info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.guide-section .info-grid > div {
    font-size: 0.875rem;
}

.guide-section .label {
    color: var(--text-secondary, #6b7280);
}

.tips-block {
    background: var(--bg-secondary, #f9fafb);
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color, #3b82f6);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark, #2563eb);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-primary, #1a1a2e);
}

.btn-outline:hover {
    background: var(--bg-secondary, #f9fafb);
}

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

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

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

.btn-xs {
    padding: 4px 8px;
    font-size: 0.75rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary, #6b7280);
}

.empty-state p {
    margin-bottom: 20px;
}

.empty-text {
    color: var(--text-secondary, #6b7280);
    text-align: center;
    padding: 20px;
}

/* Help Text */
.help-text {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 8px;
}

/* Toast Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}

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

    .page-header-right {
        width: 100%;
    }

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

    .form-group.full-width {
        grid-column: span 1;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .environment-charts {
        grid-template-columns: 1fr;
    }

    .harvest-summary-stats {
        flex-direction: column;
        gap: 16px;
    }

    .overview-info {
        grid-template-columns: 1fr;
    }

    .guide-section .info-grid {
        grid-template-columns: 1fr;
    }
}

/* Dark Theme Support */
[data-theme="dark"] {
    --card-bg: #1e293b;
    --bg-secondary: #0f172a;
    --border-color: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --primary-light: #1e3a5f;
}

[data-theme="dark"] .modal-content,
[data-theme="dark"] .garden-card,
[data-theme="dark"] .guide-card,
[data-theme="dark"] .log-entry,
[data-theme="dark"] .bed-card,
[data-theme="dark"] .chart-container {
    background: var(--card-bg);
}

[data-theme="dark"] .stat-card,
[data-theme="dark"] .data-table th {
    background: var(--bg-secondary);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}
