* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
    border-radius: 2px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
    min-height: 100vh;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

* {
    -webkit-tap-highlight-color: transparent;
}

.screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.hidden {
    display: none !important;
}

/* Login Screen */
.login-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
    width: 100%;
    max-width: 400px;
    border: 1px solid #dadce0;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #202124;
    font-weight: 400;
}

/* Main App Screen */
#appScreen {
    flex-direction: column;
    align-items: stretch;
    padding: 2rem;
}

header {
    background: white;
    padding: 1.5rem 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border: 1px solid #dadce0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    height: 50px;
    width: auto;
}

.logo-container {
    text-align: center;
    margin-bottom: 1rem;
}

.logo {
    max-height: 80px;
    width: auto;
}

header h1 {
    color: #202124;
    margin: 0;
    font-weight: 400;
    font-size: 1.375rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.language-selector select {
    padding: 0.5rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}

.language-selector select:focus {
    outline: none;
    border-color: #667eea;
}

main {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    border: 1px solid #dadce0;
}

/* Calendar Controls */
.calendar-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.view-selector {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.view-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #ddd;
    background: white;
    color: #666;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.view-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.view-btn.active {
    background: #1a73e8;
    color: white;
    border-color: #1a73e8;
}

.view-btn:hover {
    border-color: #1a73e8;
    color: #1a73e8;
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.month-navigation {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.month-navigation h2 {
    color: #333;
    font-size: 1.5rem;
    min-width: 200px;
    text-align: center;
}

.nav-btn {
    padding: 0.5rem 1rem;
    font-size: 1.5rem;
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
}

.nav-btn:hover {
    background: #e0e0e0;
    transform: none;
}

.btn-secondary {
    background: #f1f3f4;
    color: #202124;
    border: 1px solid #dadce0;
}

.btn-secondary:hover {
    background: #e8eaed;
}

button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    background: #1a73e8;
    color: white;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

button:hover {
    background: #1765cc;
    box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
}

button:active {
    background: #1557b0;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3);
}

.btn-primary {
    background: #1a73e8;
}

.btn-primary:hover {
    background: #1765cc;
}

#logoutBtn {
    background: #e74c3c;
}

#logoutBtn:hover {
    background: #c0392b;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: white;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.form-group input:focus-visible,
.form-group select:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

/* Prevent zoom on iOS input focus */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="password"],
    input[type="tel"],
    input[type="date"],
    input[type="time"],
    select {
        font-size: 16px;
    }
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Calendar */
.calendar-container {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.day-header {
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    color: #666;
    border-right: 1px solid #e0e0e0;
}

.day-header:last-child {
    border-right: none;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: white;
}

.calendar-day {
    min-height: 100px;
    border-right: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    padding: 0.5rem;
    position: relative;
    background: white;
    cursor: pointer;
    transition: background-color 0.2s;
    touch-action: manipulation;
    overflow: hidden;
}

.calendar-day:hover {
    background: #f8f9fa;
}

@media (hover: none) {
    .calendar-day:active {
        background: #f8f9fa;
    }
}

/* Limit number of visible events on mobile, show "+X more" */
@media (max-width: 768px) {
    .calendar-day {
        display: flex;
        flex-direction: column;
    }
    
    .appointment-event:nth-child(n+4) {
        display: none;
    }
    
    .appointment-event.more-events {
        display: block;
        background: #764ba2;
        font-weight: 600;
    }
}

.calendar-day.other-month {
    background: #f5f5f5;
    color: #999;
}

.calendar-day.today {
    background: #fef7e0;
}

.calendar-day.today .day-number {
    background: #1a73e8;
    color: white;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.day-number {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    display: block;
}

.appointment-event {
    color: #1a73e8;
    background: #e8f0fe;
    border-left: 3px solid #1a73e8;
    padding: 0.25rem 0.5rem;
    margin: 0.25rem 0;
    border-radius: 3px;
    font-size: 0.75rem;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: all 0.2s;
    touch-action: manipulation;
    font-weight: 500;
}

.appointment-event:hover {
    background: #d2e3fc;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.appointment-event.color-1 {
    background: #e8f0fe;
    border-left-color: #1a73e8;
    color: #1a73e8;
}

.appointment-event.color-2 {
    background: #fce8e6;
    border-left-color: #d93025;
    color: #d93025;
}

.appointment-event.color-3 {
    background: #e6f4ea;
    border-left-color: #137333;
    color: #137333;
}

.appointment-event.color-4 {
    background: #fef7e0;
    border-left-color: #f9ab00;
    color: #f9ab00;
}

.appointment-event.color-5 {
    background: #e8eaf6;
    border-left-color: #5f6368;
    color: #5f6368;
}

.appointment-event.color-6 {
    background: #f3e5f5;
    border-left-color: #a142f4;
    color: #a142f4;
}

.appointment-event.color-7 {
    background: #e0f2f1;
    border-left-color: #00796b;
    color: #00796b;
}

@media (hover: none) {
    .appointment-event:active {
        opacity: 0.8;
    }
}

.appointment-event.multiple {
    background: #764ba2;
}

.btn-danger {
    background: #e74c3c;
}

.btn-danger:hover {
    background: #c0392b;
}

.users-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 0.5rem;
}

/* View Containers */
.view-container {
    width: 100%;
}

.view-container.hidden {
    display: none;
}

/* Daily View */
.daily-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.daily-appointment-card {
    background: white;
    border: 1px solid #dadce0;
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid #1a73e8;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

.daily-appointment-card:hover {
    box-shadow: 0 2px 6px rgba(60, 64, 67, 0.3), 0 4px 8px 2px rgba(60, 64, 67, 0.15);
}

.appointment-time {
    font-size: 1.1rem;
    font-weight: 500;
    color: #1a73e8;
    margin-bottom: 0.5rem;
}

.appointment-name {
    font-size: 1.2rem;
    font-weight: 400;
    color: #202124;
    margin-bottom: 0.75rem;
}

.appointment-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: #666;
    font-size: 0.9rem;
}

/* Weekly View */
.weekly-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.weekly-day {
    background: white;
    border-right: 1px solid #e0e0e0;
    min-height: 400px;
    padding: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.weekly-day:last-child {
    border-right: none;
}

.weekly-day.today {
    background: #e3f2fd;
}

.weekly-day-header {
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}

.weekly-day-name {
    font-size: 0.85rem;
    color: #666;
    text-transform: uppercase;
    font-weight: 600;
}

.weekly-day-number {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin-top: 0.25rem;
}

.weekly-day-appointments {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.weekly-appointment {
    padding: 0.5rem;
    border-radius: 3px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    border-left: 3px solid;
    margin-bottom: 0.25rem;
}

.weekly-appointment.color-1 {
    background: #e8f0fe;
    border-left-color: #1a73e8;
    color: #1a73e8;
}

.weekly-appointment.color-2 {
    background: #fce8e6;
    border-left-color: #d93025;
    color: #d93025;
}

.weekly-appointment.color-3 {
    background: #e6f4ea;
    border-left-color: #137333;
    color: #137333;
}

.weekly-appointment.color-4 {
    background: #fef7e0;
    border-left-color: #f9ab00;
    color: #f9ab00;
}

.weekly-appointment.color-5 {
    background: #e8eaf6;
    border-left-color: #5f6368;
    color: #5f6368;
}

.weekly-appointment.color-6 {
    background: #f3e5f5;
    border-left-color: #a142f4;
    color: #a142f4;
}

.weekly-appointment.color-7 {
    background: #e0f2f1;
    border-left-color: #00796b;
    color: #00796b;
}

.weekly-appointment:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transform: translateX(2px);
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #333;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #202124;
    font-weight: 400;
    font-size: 1.5rem;
}

/* Messages */
.error-message {
    color: #e74c3c;
    margin-top: 1rem;
    padding: 0.5rem;
    background: #ffeaea;
    border-radius: 5px;
    display: none;
}

.error-message.show {
    display: block;
}

.success-message {
    color: #27ae60;
    margin-top: 1rem;
    padding: 0.5rem;
    background: #eafaf1;
    border-radius: 5px;
    display: none;
}

.success-message.show {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .screen {
        padding: 0.5rem;
    }

    #appScreen {
        padding: 0.5rem;
        align-items: flex-start;
    }

    header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        padding: 1rem 0.75rem;
        margin-bottom: 1rem;
    }

    .header-left {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        width: 100%;
    }

    .header-right {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .header-logo {
        height: 35px;
    }

    header h1 {
        font-size: 1.2rem;
        margin: 0;
    }

    .header-actions {
        flex-direction: row;
        width: 100%;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-actions button {
        flex: 1;
        min-width: calc(50% - 0.25rem);
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    .language-selector {
        width: 100%;
    }

    .language-selector select {
        width: 100%;
        padding: 0.6rem;
    }

    main {
        padding: 0.75rem;
        width: 100%;
    }

    .calendar-controls {
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .view-selector {
        width: 100%;
    }

    .view-btn {
        flex: 1;
        padding: 0.6rem;
        font-size: 0.85rem;
    }

    .month-navigation {
        justify-content: space-between;
        width: 100%;
        align-items: center;
    }

    .action-buttons {
        width: 100%;
    }

    .action-buttons button {
        flex: 1;
    }

    .weekly-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .weekly-day {
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .weekly-day:last-child {
        border-bottom: none;
    }

    .daily-appointment-card {
        padding: 1rem;
    }

    .month-navigation h2 {
        font-size: 1.1rem;
        min-width: auto;
        margin: 0;
    }

    .nav-btn {
        padding: 0.5rem 1rem;
        font-size: 1.3rem;
        min-width: 44px;
        min-height: 44px;
    }

    .calendar-controls button {
        width: 100%;
        padding: 0.85rem;
        font-size: 0.9rem;
        min-height: 44px;
    }

    .calendar-container {
        border-radius: 8px;
        overflow: hidden;
    }

    .calendar-header {
        font-size: 0.7rem;
    }

    .day-header {
        padding: 0.5rem 0.2rem;
        font-weight: 600;
    }

    .calendar-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
    }

    .calendar-day {
        min-height: 80px;
        padding: 0.3rem;
        border-right: 1px solid #e0e0e0;
        border-bottom: 1px solid #e0e0e0;
    }

    .day-number {
        font-size: 0.85rem;
        font-weight: 500;
        margin-bottom: 0.3rem;
        display: block;
    }

    .appointment-event {
        font-size: 0.7rem;
        padding: 0.25rem 0.4rem;
        margin: 0.2rem 0;
        line-height: 1.3;
        min-height: 20px;
        display: flex;
        align-items: center;
    }

    .modal-content {
        width: 95%;
        padding: 1.25rem;
        max-height: 90vh;
        margin: 1rem;
    }

    .modal-content h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 0.4rem;
    }

    .form-group input,
    .form-group select {
        padding: 0.7rem;
        font-size: 16px;
        min-height: 44px;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-actions button {
        width: 100%;
        padding: 0.85rem;
        min-height: 44px;
    }

    .login-container {
        padding: 1.5rem;
        margin: 0.5rem;
        max-width: 100%;
    }

    .logo {
        max-height: 60px;
    }

    .login-container h1 {
        font-size: 1.4rem;
        margin-bottom: 1.5rem;
    }

    button {
        padding: 0.85rem 1rem;
        font-size: 0.9rem;
        min-height: 44px;
    }

    .close {
        font-size: 1.8rem;
        right: 0.75rem;
        top: 0.75rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 13px;
    }

    .screen {
        padding: 0.25rem;
    }

    #appScreen {
        padding: 0.25rem;
    }

    header {
        padding: 0.75rem 0.5rem;
    }

    .header-logo {
        height: 30px;
    }

    header h1 {
        font-size: 1rem;
    }

    .header-actions button {
        font-size: 0.8rem;
        padding: 0.6rem 0.5rem;
    }

    main {
        padding: 0.5rem;
    }

    .month-navigation h2 {
        font-size: 0.95rem;
    }

    .nav-btn {
        padding: 0.4rem 0.75rem;
        font-size: 1.2rem;
        min-width: 40px;
        min-height: 40px;
    }

    .calendar-controls button {
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    .calendar-day {
        min-height: 70px;
        padding: 0.25rem;
    }

    .day-number {
        font-size: 0.8rem;
    }

    .appointment-event {
        font-size: 0.65rem;
        padding: 0.2rem 0.3rem;
        margin: 0.15rem 0;
    }

    .modal-content {
        padding: 1rem;
        margin: 0.5rem;
        width: calc(100% - 1rem);
    }

    .modal-content h2 {
        font-size: 1.1rem;
    }

    .login-container {
        padding: 1.25rem;
        margin: 0.25rem;
    }

    .logo {
        max-height: 50px;
    }

    .login-container h1 {
        font-size: 1.2rem;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    .calendar-day {
        min-height: 60px;
        padding: 0.2rem;
    }

    .appointment-event {
        font-size: 0.6rem;
        padding: 0.15rem 0.25rem;
    }

    .day-header {
        font-size: 0.65rem;
        padding: 0.4rem 0.15rem;
    }

    header h1 {
        font-size: 0.9rem;
    }

    .header-actions button {
        font-size: 0.75rem;
        padding: 0.5rem 0.4rem;
    }
}

