/* ============================================
   FERTICALC Pro - Styles CSS
   Design Moderne & Professionnel
   © 2026 Anass Mrabih-Rabbou - AGQ Labs Maroc
   ============================================ */

/* Variables CSS */
:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #34d399;
    --secondary: #3b82f6;
    --accent: #f59e0b;
    --danger: #ef4444;

    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-input: #0f172a;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border-color: #334155;
    --border-radius: 12px;
    --border-radius-sm: 8px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);

    --tank-acid: #dc2626;
    --tank-a: #2563eb;
    --tank-b: #7c3aed;

    --transition: all 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-dark) 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.5rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.logo-text h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text .pro {
    font-size: 0.8rem;
    background: var(--accent);
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
    background-clip: initial;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: super;
}

.tagline {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.author {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* Sections */
.section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.section:hover {
    box-shadow: var(--shadow-lg);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Parameters Grid */
.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.param-card {
    background: var(--bg-input);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.param-card label {
    font-weight: 600;
    color: var(--primary);
    display: block;
    margin-bottom: 0.75rem;
}

.param-inputs {
    display: flex;
    gap: 1rem;
}

.input-group {
    flex: 1;
}

.input-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

input[type="number"],
select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Water Section */
.water-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.water-input {
    text-align: center;
}

.water-input label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.water-input input {
    text-align: center;
}

/* Tanks Container */
.tanks-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

/* Tank Sections */
.tank-section {
    position: relative;
    overflow: hidden;
}

.tank-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.tank-acid::before {
    background: linear-gradient(90deg, var(--tank-acid), #f87171);
}

.tank-a::before {
    background: linear-gradient(90deg, var(--tank-a), #60a5fa);
}

.tank-b::before {
    background: linear-gradient(90deg, var(--tank-b), #a78bfa);
}

.info-box {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--primary);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

/* Fertilizers List */
.fertilizers-list {
    min-height: 100px;
    margin-bottom: 1rem;
}

.fertilizer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    transition: var(--transition);
}

.fertilizer-item:hover {
    background: var(--bg-card-hover);
}

.fertilizer-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.fertilizer-name {
    font-weight: 500;
    min-width: 200px;
}

.fertilizer-formula {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.fertilizer-qty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fertilizer-qty input {
    width: 80px;
    text-align: center;
}

.btn-remove {
    background: var(--danger);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Tank Subtotal */
.tank-subtotal {
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
}

.subtotal-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.subtotal-row:last-child {
    margin-bottom: 0;
}

/* Buttons */
.btn-add {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-add:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-calculate {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-calculate:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Results Section */
.results-section {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-card {
    background: var(--bg-input);
    border-radius: var(--border-radius-sm);
    padding: 1.25rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.result-card.result-ph {
    border-color: var(--accent);
}

.result-card.result-ec {
    border-color: var(--primary);
}

.result-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.result-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.result-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Results Table */
.results-table-container {
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.results-table th,
.results-table td {
    padding: 0.75rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.results-table th {
    background: var(--bg-input);
    font-weight: 600;
    color: var(--text-secondary);
}

.results-table .row-water td {
    background: rgba(59, 130, 246, 0.1);
}

.results-table .row-fertilizers td {
    background: rgba(16, 185, 129, 0.1);
}

.results-table .row-total td {
    background: var(--bg-input);
    font-weight: 600;
    color: var(--primary);
}

/* Ratios Section */
.ratios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.ratio-card {
    background: var(--bg-input);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.ratio-card.optimal {
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.1);
}

.ratio-card.warning {
    border-color: var(--accent);
    background: rgba(245, 158, 11, 0.1);
}

.ratio-card.danger {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.ratio-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

.ratio-card.optimal .ratio-value {
    color: var(--primary);
}

.ratio-card.warning .ratio-value {
    color: var(--accent);
}

.ratio-card.danger .ratio-value {
    color: var(--danger);
}

.ratio-optimal {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border-color);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h3 {
    font-size: 1.25rem;
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.btn-cancel {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-cancel:hover {
    background: var(--bg-card-hover);
}

.btn-confirm {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-confirm:hover {
    background: var(--primary-dark);
}

/* Footer */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
}

.footer-content p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.footer-note {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .container {
        padding: 1rem;
    }

    .tanks-container {
        grid-template-columns: 1fr;
    }

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

    .fertilizer-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .fertilizer-name {
        min-width: auto;
    }
}

/* Custom Fertilizer Modal */
.modal-large {
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.btn-custom {
    width: 100%;
    background: linear-gradient(135deg, var(--accent), #d97706);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-custom:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.custom-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.custom-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.custom-section h4 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.custom-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.custom-grid-small {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.custom-grid-small .form-group {
    margin-bottom: 0;
}

.custom-grid-small label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.custom-grid-small input {
    padding: 0.5rem;
    font-size: 0.9rem;
    text-align: center;
}

.info-note {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--secondary);
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* Custom fertilizer badge */
.fertilizer-custom-badge {
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 0.5rem;
}

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

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

    .modal-large {
        max-height: 85vh;
    }
}