/* styles.css - Mobile Responsive */
:root {
    --primary-color: #667eea;
    --primary-hover: #5568d3;
    --secondary-color: #28a745;
    --secondary-hover: #218838;
    --error-color: #dc3545;
    --success-color: #28a745;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 20px;
    background: var(--gradient);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 500px;
    margin: 40px auto;
    padding: 0;
}

.container h2 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
    font-size: 32px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.dashboard {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-radius: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.form {
    background-color: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

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

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 15px;
    transition: all 0.3s;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

button, .btn {
    background: var(--gradient);
    color: white;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    width: 100%;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

button:hover, .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

button:active, .btn:active {
    transform: translateY(0);
}

.error {
    background: #fff3f3;
    color: var(--error-color);
    padding: 14px 16px;
    margin-bottom: 20px;
    border: 1px solid #ffcdd2;
    border-radius: 8px;
    font-size: 14px;
    border-left: 4px solid var(--error-color);
}

.success {
    background: #f1f8f4;
    color: var(--success-color);
    padding: 14px 16px;
    margin-bottom: 20px;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    font-size: 14px;
    border-left: 4px solid var(--success-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

tr:hover {
    background-color: #f8f9ff;
}

.profile-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 14px;
}

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

.logout-btn {
    background-color: var(--error-color);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 14px;
}

.logout-btn:hover {
    background-color: #c82333;
    transform: translateY(-2px);
}

.dashboard-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px 0;
}

.new-prescription, .recent-prescriptions {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.new-prescription h3, .recent-prescriptions h3 {
    margin-top: 0;
    color: #333;
    font-size: 20px;
    margin-bottom: 20px;
}

.generate-btn {
    background: var(--gradient);
    color: white;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.view-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 5px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

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

.regenerate-btn {
    background-color: var(--secondary-color);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

.regenerate-btn:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-2px);
}

textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

#dob {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    letter-spacing: 1px;
}

#dob::placeholder {
    letter-spacing: normal;
}

/* Link Styles */
.form p {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #666;
}

.form a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
}

.form a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* PWA Styles */
.install-banner {
    background: var(--gradient);
    color: white;
    padding: 20px;
    margin: 20px 0;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    animation: slideDown 0.3s ease-out;
}

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

.install-banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.install-banner-text {
    flex: 1;
}

.install-banner-text strong {
    font-size: 18px;
    display: block;
    margin-bottom: 8px;
}

.install-banner-text p {
    margin: 0;
    font-size: 14px;
    opacity: 0.95;
}

.install-banner-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.install-btn {
    background: white;
    color: var(--primary-color);
    border: none;
    padding: 12px 24px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    white-space: nowrap;
}

.install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.dismiss-btn {
    background: transparent;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0 10px;
    line-height: 1;
    transition: opacity 0.2s;
    width: auto;
}

.dismiss-btn:hover {
    opacity: 0.8;
}

/* Mobile Responsive Styles */
@media (max-width: 968px) {
    .dashboard-content {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        text-align: center;
    }

    header > div {
        width: 100%;
        display: flex;
        justify-content: center;
        gap: 10px;
    }
}

@media (max-width: 640px) {
    body {
        padding: 15px;
    }

    .container {
        margin: 20px auto;
    }

    .container h2 {
        font-size: 26px;
        margin-bottom: 20px;
    }

    .form {
        padding: 30px 25px;
        border-radius: 12px;
    }

    header {
        padding: 15px;
    }

    header h2 {
        font-size: 20px;
    }

    .new-prescription, .recent-prescriptions {
        padding: 20px;
    }

    table {
        font-size: 14px;
    }

    th, td {
        padding: 10px 8px;
    }

    button, .btn {
        padding: 12px 20px;
        font-size: 15px;
    }

    .install-banner {
        padding: 16px;
    }

    .install-banner-content {
        flex-direction: column;
        text-align: center;
    }

    .install-banner-text strong {
        font-size: 16px;
    }

    .install-banner-actions {
        width: 100%;
        justify-content: center;
    }

    .install-btn {
        flex: 1;
    }

    /* Make tables scrollable on mobile */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Stack action buttons vertically on mobile */
    td button {
        display: block;
        width: 100%;
        margin: 4px 0;
    }
}

@media (max-width: 400px) {
    .container h2 {
        font-size: 22px;
    }

    .form {
        padding: 25px 20px;
    }

    input, select, textarea {
        padding: 10px 14px;
        font-size: 14px;
    }

    button, .btn {
        padding: 10px 18px;
        font-size: 14px;
    }

    .new-prescription, .recent-prescriptions {
        padding: 16px;
    }
}

/* PWA Standalone Mode */
@media all and (display-mode: standalone) {
    .install-banner {
        display: none !important;
    }

    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #ffc107;
    color: #000;
    padding: 12px 20px;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-weight: 600;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
    font-size: 14px;
}

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

.offline-indicator.online {
    background: var(--success-color);
    color: white;
}

@media (max-width: 640px) {
    .offline-indicator {
        bottom: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
        font-size: 13px;
    }
}
