/* =========================================
   1. GLOBAL VARIABLES & RESET
   ========================================= */
:root {
    /* Brand Colors */
    --primary: #10b981;       /* Agri Green */
    --midnight: #0f172a;      /* Deep Navy/Black (Primary Actions) */

    /* Layout Colors */
    --bg-body: #f8fafc;       /* Light Slate Background */
    --surface: #ffffff;       /* Pure White Cards */
    --border: #e2e8f0;        /* Subtle Borders */

    /* Text Colors */
    --text-main: #0f172a;     /* Darkest Black */
    --text-muted: #64748b;    /* Muted Gray */

    /* UI Elements */
    --radius: 16px;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    background-color: var(--bg-body);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    margin: 0;
}

/* Main Container for all pages */
.page-container, .page-wrapper, .activity-screen, .show-container {
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 20px;
}

/* =========================================
   2. HEADERS & TITLES
   ========================================= */
.header-section, .page-header, .activity-header {
    margin-bottom: 30px;
    text-align: left;
}

/* Centered header specifically for Forms */
.activity-header { text-align: center; }

h1, h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 12px;
}

.subtitle, .activity-subtitle {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 1rem;
}

/* Header Icons (Circle behind icons) */
.header-icon {
    width: 50px;
    height: 50px;
    background: #eff6ff;
    color: #2563eb;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}
.activity-header .header-icon { margin: 0 auto 15px; } /* Center in forms */

/* =========================================
   3. BUTTONS (SOFT BRAND STYLE)
   ========================================= */
/* Base Button Style */
.btn-action, .btn-primary, .btn-edit, .btn-delete, .btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

/* PRIMARY / SAVE (Midnight Blue) */
/* Used for "New Activity" and "Save" */
.btn-primary, .btn-submit {
    background-color: var(--midnight);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.3);
}

.btn-primary:hover, .btn-submit:hover {
    background-color: #1e293b;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.3);
}

/* EDIT BUTTON (Soft Brand Green) */
.btn-edit {
    background-color: #ecfdf5;  /* Very Light Mint */
    color: #059669;             /* Deep Emerald Text */
    border: 1px solid #d1fae5;  /* Subtle Green Border */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-edit:hover {
    background-color: #10b981;  /* Turns Solid Green */
    color: #ffffff;             /* White Text */
    border-color: #10b981;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.25); /* Green Glow */
}

/* DELETE BUTTON (Soft Danger Red) */
.btn-delete {
    background-color: #fef2f2;  /* Very Light Pink */
    color: #dc2626;             /* Deep Red Text */
    border: 1px solid #fee2e2;  /* Subtle Red Border */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-delete:hover {
    background-color: #ef4444;  /* Turns Solid Red */
    color: #ffffff;             /* White Text */
    border-color: #ef4444;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.25); /* Red Glow */
}

/* BACK BUTTON (Ghost Pill) */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: #ffffff;
    border: 1px solid var(--border);
    border-radius: 50px;
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-back:hover {
    background-color: #f0fdf4;
    color: #15803d;
    border-color: var(--primary);
    transform: translateX(-3px);
}

/* =========================================
   4. INDEX PAGE: TOOLBAR & SEARCH
   ========================================= */
.toolbar, .header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 25px;
}

.search-form {
    flex-grow: 1;
    max-width: 450px;
}

.search-container {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 50px;
    padding: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.search-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.search-icon-overlay {
    color: #94a3b8;
    margin-left: 15px;
    flex-shrink: 0;
}

.search-input {
    border: none;
    background: transparent;
    flex-grow: 1;
    padding: 10px 15px;
    font-size: 0.95rem;
    color: var(--text-main);
    outline: none;
}

.search-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 8px 24px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}
.search-btn:hover { background-color: #059669; }

/* =========================================
   5. INDEX PAGE: TABLE & STATUS
   ========================================= */
.table-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 30px;
}

.activities-table {
    width: 100%;
    border-collapse: collapse;
}

.activities-table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 18px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.activities-table td {
    padding: 18px 24px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
    vertical-align: middle;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.status-completed { background: #d1fae5; color: #047857; }
.status-progress  { background: #dbeafe; color: #1d4ed8; }
.status-pending   { background: #fff7ed; color: #c2410c; }
.status-cancelled { background: #fee2e2; color: #b91c1c; }

/* View Button in Table */
.btn-view {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 6px 14px;
    border-radius: 8px;
    text-decoration: none;
}
.btn-view:hover { background: var(--primary); color: white; }

/* =========================================
   6. SHOW PAGE: DETAILS GRID
   ========================================= */
.activity-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    border: 1px solid white;
    overflow: hidden;
}

/* The Magic Grid for Rails Partials */
.details-grid p {
    margin: 0;
    padding: 24px 32px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
}
.details-grid p:last-child { border-bottom: none; }

.details-grid strong {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}
.details-grid p { color: var(--text-main); font-weight: 500; }

.card-footer {
    background: #f8fafc;
    padding: 20px 32px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* =========================================
   7. FORM PAGE: INPUTS
   ========================================= */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group { margin-bottom: 24px; }

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.modern-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    background-color: #f1f5f9;
    border: 2px solid transparent;
    border-radius: 12px;
    color: var(--text-main);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.modern-input:focus {
    outline: none;
    background-color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

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

/* =========================================
   8. MISC: NOTIFICATION & PAGINATION
   ========================================= */
.notice-banner, .flash-notice {
    background: #ecfdf5;
    color: #065f46;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid #6ee7b7;
}

.footer-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
}

.pagination nav { display: flex; gap: 5px; }
.pagination a, .pagination span {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    text-decoration: none;
    color: var(--text-muted);
}
.pagination .current { background: var(--primary); color: white; border-color: var(--primary); }

/* =========================================
   9. MOBILE RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    /* General */
    .header-flex, .toolbar, .card-footer { flex-direction: column; align-items: stretch; }
    .btn-action, .search-form { width: 100%; }

    /* Table */
    .activities-table thead { display: none; }
    .activities-table tr { display: block; border-bottom: 8px solid var(--bg-body); }
    .activities-table td { display: flex; justify-content: space-between; padding: 12px 20px; border: none; }
    .activities-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.8rem;
        text-transform: uppercase;
    }

    /* Details Grid */
    .details-grid p { flex-direction: column; align-items: flex-start; gap: 6px; }

    /* Form */
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .activity-card { padding: 25px; }
}