/* --- VARIABLES --- */
:root {
    --primary-green: #014d25; /* Faith Hospital Green */
    --light-green: #e8f5e9;
    --border-color: #ced4da;
    --bg-color: #f8f9fa;
}

body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(--bg-color); margin: 0; padding: 20px; }
.container { max-width: 1280px; margin: 0 auto; }

/* HEADER */
.main-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.brand { display: flex; align-items: center; gap: 15px; }
.brand img { height: 65px; }
.brand-text { display: flex; flex-direction: column; }
.brand h1 { 
    color: var(--primary-green); font-size: 26px; font-weight: 800; margin: 0; 
    text-transform: uppercase; letter-spacing: 0.5px; line-height: 1.1; 
}
.brand .sub-header { 
    color: var(--primary-green); font-size: 13px; font-weight: 700; margin-top: 2px; 
    letter-spacing: 1px; text-transform: uppercase; 
}

.nav-buttons { display: flex; gap: 8px; }
.nav-btn { 
    padding: 8px 16px; border: 1px solid var(--primary-green); background: white; 
    color: var(--primary-green); border-radius: 4px; cursor: pointer; font-weight: 600; 
    text-decoration: none; display: inline-flex; align-items: center; gap: 5px; font-size: 14px;
}
.nav-btn.active { background: var(--primary-green); color: white; }
.nav-btn:hover { opacity: 0.9; }

/* FORM CARD */
.form-card { 
    background: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); 
    padding: 25px; border-top: 4px solid var(--primary-green); margin-bottom: 30px;
}
.input-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 15px; align-items: start; }

.col-date { grid-column: span 2; }
.col-name { grid-column: span 3; }
.col-address { grid-column: span 3; } 
.col-age { grid-column: span 1; }
.col-sex { grid-column: span 1; }
.col-phone { grid-column: span 2; }
.col-vitals { grid-column: span 12; display: flex; gap: 15px; padding-top: 15px; border-top: 1px dashed #ddd; margin-top: 5px; align-items: flex-end;}

.form-group { display: flex; flex-direction: column; }
.form-group label { font-size: 11px; font-weight: 700; color: #666; margin-bottom: 4px; text-transform: uppercase; }
.form-control { 
    padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 4px; 
    font-size: 14px; transition: 0.2s; width: 100%; box-sizing: border-box;
}
.form-control:focus { border-color: var(--primary-green); outline: none; }

.btn-submit { background: #198754; color: white; border: none; padding: 0 25px; border-radius: 4px; font-weight: 600; cursor: pointer; height: 35px; }
.btn-update { background: #ffc107; color: #000; }

/* SEARCH & TABLE */
.search-row { display: flex; gap: 10px; margin-bottom: 20px; }
.search-input { flex-grow: 1; padding: 12px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 15px; }
.btn-search-main { background: var(--primary-green); color: white; border: none; padding: 0 30px; border-radius: 4px; font-weight: bold; cursor: pointer; font-size: 15px;}

.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.data-table th { background: var(--primary-green); color: white; text-align: left; padding: 12px 15px; font-size: 13px; text-transform: uppercase; }
.data-table td { padding: 10px 15px; border-bottom: 1px solid #eee; font-size: 14px; color: #333; }
.data-table tr:hover { background-color: #f8f9fa; }

.action-link { margin-right: 10px; text-decoration: none; font-weight: 500; font-size: 13px; }
.edit-link { color: #d68c0b; }
.delete-link { color: #dc3545; }

.patient-name-link { color: var(--primary-green); font-weight: 700; text-decoration: none; cursor: pointer; display: block; }
.patient-name-link:hover { text-decoration: underline; }
.expand-icon { font-size: 10px; margin-left: 5px; color: #666; transition: transform 0.2s; display: inline-block;}
.opd-row.active .expand-icon { transform: rotate(180deg); }

/* CALENDARS COMMON */
#calendar-container, #week-container { display: none; background: white; padding: 20px; border-radius: 12px; margin-bottom: 25px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.cal-header span { font-weight: 700; color: #444; cursor: pointer; user-select: none; }
#cal-title, #week-title { font-size: 18px; color: var(--primary-green); text-transform: uppercase; }

/* MONTH GRID */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-cell { background: #f8f9fa; min-height: 90px; padding: 8px; border-radius: 6px; cursor: pointer; border: 1px solid #eee; transition: 0.2s; }
.cal-cell:hover { border-color: var(--primary-green); background: #f0fdf4; }
.cal-badge { display: block; background: var(--primary-green); color: white; font-size: 10px; padding: 3px 6px; border-radius: 10px; text-align: center; margin-top: 5px; font-weight: 600; }
.cal-cell.today { border: 2px solid var(--primary-green); background-color: #f0fdf4; font-weight: bold; box-shadow: 0 4px 10px rgba(1, 77, 37, 0.15); }

/* WEEK VIEW */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 15px; overflow-x: auto; padding-bottom: 5px; }
.week-col { background: #f8f9fa; border-radius: 12px; min-width: 140px; display: flex; flex-direction: column; overflow: hidden; border: 1px solid transparent; }
.week-col.today { background: #fff; border: 2px solid var(--primary-green); box-shadow: 0 4px 12px rgba(1, 77, 37, 0.15); }
.week-head { padding: 15px; display: flex; flex-direction: column; border-bottom: 1px solid #eee; }
.week-col.today .week-head { background: var(--primary-green); }
.day-name { font-size: 12px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px; }
.day-num { font-size: 28px; font-weight: 800; color: #333; line-height: 1; }
.week-col.today .day-name { color: rgba(255,255,255,0.8); }
.week-col.today .day-num { color: white; }
.week-body { padding: 10px; flex-grow: 1; min-height: 180px; display: flex; flex-direction: column; gap: 8px; }
.week-item { background: white; padding: 10px 12px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.04); font-size: 13px; font-weight: 600; color: #333; border-left: 4px solid var(--primary-green); cursor: pointer; transition: all 0.2s ease; }
.week-item:hover { transform: translateY(-3px); box-shadow: 0 5px 10px rgba(0,0,0,0.1); }
.empty-msg { text-align: center; font-size: 12px; color: #adb5bd; margin-top: 40px; font-style: italic; }

.total-box { background: var(--primary-green); color: white; padding: 10px; margin-top: 15px; text-align: center; font-weight: bold; border-radius: 4px; font-size: 16px; }

/* EXPANDABLE ROW */
.opd-row { display: none; }
.opd-row.active { display: table-row; background: #fafafa; }
.expand-wrapper { padding: 20px; display: flex; justify-content: center; }

/* --- PRINT CARD --- */
.a4-card { width: 210mm; min-height: 297mm; background: white; padding: 10mm; box-sizing: border-box; font-family: "Times New Roman", Times, serif; color: #000; position: relative; border: 1px solid #ccc; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.card-header-grid { display: grid; grid-template-columns: 80px 1fr 190px; gap: 5px; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 10px; }
.logo-area img { width: 75px; height: 75px; }
.title-area { text-align: center; display: flex; flex-direction: column; justify-content: center; }

.main-title { font-size: 20px; font-weight: 900; margin: 0; line-height: 1.1; color: #014d25; white-space: nowrap; }
.sub-title, .phone-text, .opd-label, .quote-box { color: #014d25; font-weight: bold; }
.sub-title { font-size: 14px; margin: 3px 0; }
.phone-text { font-size: 14px; margin: 0; }
.opd-label { font-size: 20px; margin-top: 8px; text-decoration: underline; text-underline-offset: 3px; }
.quote-box { text-align: center; border: 1px solid #014d25; padding: 3px 5px; font-style: italic; font-size: 14px; margin-top: 8px; display: inline-block; width: 90%; align-self: center;}

.timing-box { border: 1px solid #000; padding: 5px; font-size: 11px; font-family: Arial, sans-serif; line-height: 1.3; text-align: center; }
.timing-header { font-weight: bold; text-decoration: underline; margin-bottom: 2px; }
.timing-row { display: block; margin-bottom: 2px; }
.mizo-text { margin-top: 6px; font-size: 10px; font-style: italic; line-height: 1.1; }

.details-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.input-line-row { display: flex; align-items: flex-end; width: 100%; }
.field-label { font-weight: bold; font-size: 14px; margin-right: 5px; white-space: nowrap; }
.field-value { flex-grow: 1; border-bottom: 1px solid #000; font-size: 15px; padding-left: 10px; position: relative; top: -2px; }

/* UPDATED: Increased Height & Footer Positioning */
.main-content-area { 
    display: flex; 
    height: 215mm; /* Increased height to push footer down */
    border: 1px solid #000; 
    margin-top: 5px; 
}
.left-sidebar { width: 25%; border-right: 1px solid #000; display: flex; flex-direction: column; }
.vitals-box { padding: 5px; border-bottom: 1px solid #000; }
.vital-row { display: flex; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: bold; }
.vital-line { flex-grow: 1; border-bottom: 1px solid #000; height: 14px; margin: 0 5px; text-align: center; font-weight: normal; font-family: Arial; }
.vital-unit { font-size: 11px; }

.investigations-area { padding: 5px; font-weight: bold; text-decoration: underline; }
.right-notes-area { width: 75%; position: relative; }

/* UPDATED: Pinned to bottom-most edge */
.footer-stamp { 
    position: absolute; 
    bottom: 0px; 
    right: 15px; 
    text-align: center; 
    font-weight: bold; 
    font-size: 14px; 
    line-height: 1.4;
    padding-bottom: 5px; /* Slight buffer */
}

.print-btn { position: absolute; top: -40px; right: 0; background: #014d25; color: white; border: none; padding: 8px 15px; cursor: pointer; font-weight: bold; border-radius: 4px; }

@media print {
    @page { size: A4; margin: 0; }
    body * { visibility: hidden; }
    .a4-card, .a4-card * { visibility: visible; }
    .a4-card { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0; display: block; border: none; box-shadow: none; }
    .print-btn { display: none; }
}