/* Global Resets & Base Styles */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #333;
}

body {
    background: #f5f5f5;
}

/* Remove default button styles */
button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    outline: none;
}

/* Utility Classes */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Timeline Styles (for daily view) */
.timeline-container {
    background: white;
    min-height: 100vh;
}

.timeline-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 1.5rem 1rem;
    border-bottom: 2px solid #e0e0e0;
    z-index: 50;
}

    .timeline-header h2 {
        margin: 0 0 0.5rem 0;
        font-size: 1.5rem;
        color: #333;
    }

.timeline-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.stat-badge {
    background: #f0f0f0;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-weight: 500;
}

    .stat-badge.taken {
        background: #d4edda;
        color: #155724;
    }

    .stat-badge.pending {
        background: #fff3cd;
        color: #856404;
    }

    .stat-badge.overdue {
        background: #f8d7da;
        color: #721c24;
    }

/* Timeline Hour Rows */
.timeline-content {
    padding: 0;
}

.timeline-hour {
    display: flex;
    border-bottom: 1px solid #f0f0f0;
    min-height: 60px;
}

.hour-label {
    width: 70px;
    padding: 1rem 0.5rem;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: #999;
    border-right: 2px solid #e0e0e0;
    flex-shrink: 0;
}

.hour-content {
    flex: 1;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Current Time Indicator */
.current-time-marker {
    position: relative;
}

.current-time-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, rgba(102, 126, 234, 0) 100%);
    border-left: 3px solid #667eea;
}

.time-dot {
    width: 12px;
    height: 12px;
    background: #667eea;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(102, 126, 234, 0.1);
    }
}

.time-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #667eea;
}

/* Med Cards */
.med-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

    .med-card:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .med-card.taken {
        border-color: #28a745;
        background: #f8fff9;
    }

    .med-card.overdue {
        border-color: #dc3545;
        background: #fff8f8;
    }

    .med-card.skipped {
        border-color: #999;
        background: #f9f9f9;
        opacity: 0.7;
    }

.med-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.med-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.med-dosage {
    font-size: 0.9rem;
    color: #666;
    margin: 0.25rem 0;
}

.med-status {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

    .med-status.taken {
        color: #28a745;
        font-weight: 600;
    }

    .med-status.overdue {
        color: #dc3545;
        font-weight: 600;
    }

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: #667eea;
    color: white;
}

    .btn-primary:hover {
        background: #5568d3;
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
    }

.btn-success {
    background: #28a745;
    color: white;
}

    .btn-success:hover {
        background: #218838;
    }

.btn-secondary {
    background: #6c757d;
    color: white;
}

    .btn-secondary:hover {
        background: #5a6268;
    }

.btn-outline {
    background: white;
    border: 2px solid #e0e0e0;
    color: #666;
}

    .btn-outline:hover {
        border-color: #999;
        color: #333;
    }

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.med-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

    .med-actions .btn {
        flex: 1;
    }

/* Loading & Empty States */
.loading-spinner {
    text-align: center;
    padding: 3rem;
    color: #999;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

    .empty-state p {
        color: #999;
        font-size: 1.1rem;
        margin-bottom: 1.5rem;
    }

/* Desktop adjustments */
@media (min-width: 768px) {
    .timeline-container {
        margin-left: 0;
    }

    .med-card {
        max-width: 600px;
    }

    .hour-label {
        width: 100px;
    }
}

/* Medications Management Page Styles */
.medications-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

.medications-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
}

    .medications-header h2 {
        margin: 0;
        font-size: 1.75rem;
    }

.med-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    cursor: pointer;
    user-select: none;
}

    .med-card-header:hover {
        background: #f9f9f9;
    }

.med-info h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.25rem;
    color: #333;
}

.dosage-text {
    margin: 0.25rem 0;
    color: #666;
    font-size: 0.9rem;
}

.schedule-summary {
    margin: 0.5rem 0 0 0;
    color: #999;
    font-size: 0.85rem;
}

.expand-icon {
    font-size: 1.2rem;
    color: #999;
    transition: transform 0.2s;
}

.med-card.expanded .expand-icon {
    transform: rotate(90deg);
}

.med-card-body {
    padding: 1rem;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.med-edit-card {
    background: white;
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

    .med-edit-card h3 {
        margin: 0 0 1rem 0;
        color: #667eea;
    }

.med-details {
    margin-bottom: 1.5rem;
}

    .med-details p {
        margin: 0.5rem 0;
    }

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

    .form-group label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 600;
        color: #333;
        font-size: 0.9rem;
    }

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

    .form-input:focus {
        outline: none;
        border-color: #667eea;
    }

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Schedules Section */
.schedules-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

    .section-header h4 {
        margin: 0;
        font-size: 1.1rem;
        color: #333;
    }

.schedule-form {
    background: white;
    border: 2px solid #28a745;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.days-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.day-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

    .day-checkbox input[type="checkbox"] {
        margin: 0;
    }

    .day-checkbox:has(input:checked) {
        background: #667eea;
        border-color: #667eea;
        color: white;
    }

.schedules-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.schedule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.schedule-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.schedule-time {
    font-weight: 600;
    color: #333;
}

.schedule-desc {
    font-size: 0.85rem;
    color: #666;
}

.btn-delete {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f8d7da;
    color: #721c24;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
}

    .btn-delete:hover {
        background: #dc3545;
        color: white;
    }

.empty-schedules {
    padding: 1rem;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

/* Danger Zone */
.danger-zone {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #f8d7da;
}

/* History & Statistics Page Styles */
.history-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

.history-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
}

    .history-header h2 {
        margin: 0;
        font-size: 1.75rem;
    }

.date-range-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.range-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    color: #666;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

    .range-btn:hover {
        border-color: #667eea;
        color: #667eea;
    }

    .range-btn.active {
        background: #667eea;
        border-color: #667eea;
        color: white;
    }

.stats-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

    .stats-card h3 {
        margin: 0 0 1.5rem 0;
        font-size: 1.25rem;
        color: #333;
    }

.adherence-chart {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.adherence-circle {
    position: relative;
    width: 150px;
    height: 150px;
    flex-shrink: 0;
}

    .adherence-circle svg {
        width: 100%;
        height: 100%;
        transform: rotate(-90deg);
    }

.circle-bg {
    fill: none;
    stroke: #f0f0f0;
    stroke-width: 8;
}

.circle-progress {
    fill: none;
    stroke: #28a745;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 251.2;
    transition: stroke-dashoffset 0.5s ease;
}

.adherence-percentage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 700;
    color: #333;
}

.adherence-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
}

    .stat-icon.taken {
        background: #d4edda;
        color: #155724;
    }

    .stat-icon.missed {
        background: #f8d7da;
        color: #721c24;
    }

    .stat-icon.skipped {
        background: #e2e3e5;
        color: #383d41;
    }

    .stat-icon.upcoming {
        background: #fff3cd;
        color: #856404;
    }

.stat-label {
    flex: 1;
    font-weight: 500;
    color: #666;
}

.stat-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: #333;
}

.medication-stats {
    margin-bottom: 2rem;
}

    .medication-stats h3 {
        margin: 0 0 1rem 0;
        font-size: 1.25rem;
        color: #333;
    }

.med-stat-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.med-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

    .med-stat-header h4 {
        margin: 0;
        font-size: 1.1rem;
        color: #333;
    }

.adherence-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
}

.med-stat-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-bar {
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

    .bar-fill.taken {
        background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    }

.stat-counts {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
}

.count-item {
    color: #666;
}

    .count-item.taken {
        color: #28a745;
    }

    .count-item.missed {
        color: #dc3545;
    }

    .count-item.skipped {
        color: #6c757d;
    }

.filter-section {
    margin-bottom: 1.5rem;
}

    .filter-section h3 {
        margin: 0 0 0.75rem 0;
        font-size: 1.25rem;
        color: #333;
    }

.logs-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.log-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #e0e0e0;
}

    .log-item.log-taken {
        border-left-color: #28a745;
        background: #f8fff9;
    }

    .log-item.log-missed {
        border-left-color: #dc3545;
        background: #fff8f8;
    }

    .log-item.log-skipped {
        border-left-color: #6c757d;
        background: #f9f9f9;
    }

.log-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 70px;
}

.log-day {
    font-weight: 700;
    font-size: 0.9rem;
    color: #333;
}

.log-time {
    font-size: 0.8rem;
    color: #999;
}

.log-info {
    flex: 1;
}

.log-med-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.log-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-text {
    font-size: 0.9rem;
}

    .status-text.taken {
        color: #28a745;
    }

    .status-text.missed {
        color: #dc3545;
    }

    .status-text.skipped {
        color: #6c757d;
    }

.log-notes {
    font-size: 0.85rem;
    color: #999;
    font-style: italic;
}

.logs-note {
    text-align: center;
    padding: 1rem;
    color: #999;
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    .adherence-chart {
        flex-direction: column;
    }

    .adherence-circle {
        width: 120px;
        height: 120px;
    }

    .adherence-percentage {
        font-size: 1.5rem;
    }
}

/* Register/Login Page Styles */
.register-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
}

.register-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

    .register-card h1 {
        text-align: center;
        margin: 0 0 0.5rem 0;
        font-size: 2rem;
        color: #667eea;
    }

    .register-card h2 {
        text-align: center;
        margin: 0 0 1.5rem 0;
        font-size: 1.5rem;
        color: #333;
    }

.login-link {
    text-align: center;
    margin-top: 1.5rem;
    color: #666;
}

    .login-link a {
        color: #667eea;
        text-decoration: none;
        font-weight: 600;
    }

        .login-link a:hover {
            text-decoration: underline;
        }

.w-100 {
    width: 100%;
}

.checkbox-group {
    margin: 1rem 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

    .checkbox-label input[type="checkbox"] {
        width: 18px;
        height: 18px;
        cursor: pointer;
    }

    .checkbox-label span {
        color: #666;
        font-size: 0.95rem;
    }
